Skip to content

First we need to check the token auth module - otherwise we DOS the u… - #30364

Merged
PVince81 merged 1 commit into
masterfrom
bugfix/30157
Feb 6, 2018
Merged

PVince81 merged 1 commit into
masterfrom
bugfix/30157

Conversation

@DeepDiver1975

@DeepDiver1975 DeepDiver1975 commented Feb 5, 2018 •

Copy link
Copy Markdown
Contributor

…ser backends with wrong login requests

Description

Login requests to the user backends (using IUserManager::checkPassword) need to be the last operation to be tried because this will cause logout of the user in worst case.

As a result any other auth checks need to be performed before (cookies, oauth and so on).

Related Issue

fixes #30157

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@DeepDiver1975 DeepDiver1975 added this to the development milestone Feb 5, 2018
@DeepDiver1975 DeepDiver1975 self-assigned this Feb 5, 2018
@ownclouders ownclouders added blue-ticket Type:Bug p1-urgent Critical issue, need to consider hotfix with just that issue security labels Feb 5, 2018
@IljaN IljaN mentioned this pull request Feb 5, 2018
3 of 9 tasks

@IljaN IljaN left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Just did a test, error is gone. 👍 If we can`t think of any side-effects this reordering might have.

@codecov

codecov Bot commented Feb 5, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #30364 into master will increase coverage by 0.2%.
The diff coverage is 79.16%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #30364     +/-   ##
===========================================
+ Coverage     60.64%   60.84%   +0.2%     
  Complexity    18549    18549             
===========================================
  Files          1092     1092             
  Lines         61278    61280      +2     
===========================================
+ Hits          37160    37286    +126     
+ Misses        24118    23994    -124
Impacted Files Coverage Δ Complexity Δ
lib/private/User/Session.php 58.91% <79.16%> (ø) 139 <0> (ø) ⬇️
lib/private/Repair/SqliteAutoincrement.php 85.18% <0%> (-3.28%) 9% <0%> (ø)
lib/private/DB/AdapterSqlite.php 83.33% <0%> (-2.88%) 7% <0%> (ø)
lib/private/Files/View.php 84.41% <0%> (+0.3%) 377% <0%> (ø) ⬇️
lib/private/Repair/RepairMismatchFileCachePath.php 82.52% <0%> (+0.4%) 48% <0%> (ø) ⬇️
lib/private/DB/QueryBuilder/QueryBuilder.php 90.74% <0%> (+0.46%) 68% <0%> (ø) ⬇️
lib/private/DB/Connection.php 68.38% <0%> (+4.41%) 49% <0%> (ø) ⬇️
lib/private/DB/MDB2SchemaManager.php 85.96% <0%> (+5.26%) 17% <0%> (ø) ⬇️
...private/DB/MySqlSchemaColumnDefinitionListener.php 5.4% <0%> (+5.4%) 46% <0%> (ø) ⬇️
lib/private/DB/MDB2SchemaWriter.php 92.7% <0%> (+6.25%) 34% <0%> (ø) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05a5776...58cb14e. Read the comment docs.

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for a workaround 👍

However, from looking at the fix, it seems to imply that the "Login failed" error is actually logged by BasicAuthModule since it used to appear before. Now with this workaround it will appear at the end, so the behavior is correct. I'd prefer if we have the code outside of this log the entry, once all modules failed, instead of having the logging code specific to BasicAuthModule. This way we're not dependent on the order.

@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

I'd prefer if we have the code outside of this log the entry, once all modules failed, instead of having the logging code specific to BasicAuthModule. This way we're not dependent on the order.

absolutly reasonable - but thinking about ldap it is still necessary to execute the checkPassword command within the last module - failed logins to ldap need to be prevented because they are causing logouts within ldap

@PVince81
PVince81 merged commit 55fb4c2 into master Feb 6, 2018
@PVince81
PVince81 deleted the bugfix/30157 branch February 6, 2018 10:18
@PVince81

PVince81 commented Feb 6, 2018 •

Copy link
Copy Markdown
Contributor

please backport to stable10 hotfix-10.0.7

would be nice to only backport the relevant change, not the code styling ones...

@PVince81

PVince81 commented Feb 6, 2018

Copy link
Copy Markdown
Contributor

backport to hotfix branch instead ^

we'll merge it back

@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

backport to hotfix branch instead ^

Will open a new pr with the actual fix only

@SamuAlfageme

Copy link
Copy Markdown

👍 Manages to get rid of the error in basic auth schemas.

⚠️ Still throws the "Login Failed" messages when using OAuth2 together with application passwords:

{"reqId":"784b6f28-87b4-40b8-b76a-cd1c2e034234","level":2,"time":"2018-02-07T12:08:51+00:00","remoteAddr":"172.17.0.1","user":"--","app":"core","method":"POST","url":"\/index.php\/apps\/oauth2\/api\/v1\/token","message":"Login failed: 'xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69' (Remote IP: '172.17.0.1')"}
172.17.0.1 - xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69 [07/Feb/2018:12:08:51 +0000] "POST /index.php/apps/oauth2/api/v1/token HTTP/1.1" 200 1322 "-" "Mozilla/5.0 (Macintosh) mirall/2.4.0 (build 8836)"

Still need to check together with #30365 + owncloud/oauth2#112 but I guess 10.0.7 should contain the fix

@DeepDiver1975

Copy link
Copy Markdown
Contributor Author

Still throws the "Login Failed" messages when using OAuth2 together with application passwords:

I know why ..... hmmmm - do we want this in 10.0.7 as well? One line change
@PVince81 @SamuAlfageme

@PVince81

PVince81 commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

@DeepDiver1975 yes please

@PVince81

Copy link
Copy Markdown
Contributor

@DeepDiver1975 is this something we need to backport ? Seems to be auth related. Not sure if obsoleted by any of the other recent auth changes. How risky ?

@lock

lock Bot commented Jul 31, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3 - To Review blue-ticket p1-urgent Critical issue, need to consider hotfix with just that issue security Type:Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[10.0.4] Sessions created from application passwords result in "Login failed" errors when used

5 participants