passlib failure to sanitize env variables PASSLIB_MAX_PASSWORD_SIZE

Bug #1175905 reported by Kurt Seifried
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Low
Eric Brown

Bug Description

Grant Murphy originally reported:

* Usage of passlib

  The keystone server does not appear to sanitize the environment when
  starting. This means that an unintended value can be set for
  PASSLIB_MAX_PASSWORD_SIZE. Which will overwrite the default value of
  4096 and potentially cause an unhandled passlib.exc.PasswordSizeError.
  We should ensure sensible defaults are applied here prior to loading passlib.

If this is exploitable it will need a CVE, if not we should still harden it so it can't be monkeyed with in the future.

Tags: security
Revision history for this message
Thierry Carrez (ttx) wrote :

I don't see this as exploitable, as you'd have to locally control the environment for the keystone user, which means control of that user which means pretty much controlling Keystone anyway ?

Fully agree that we can strengthen that part to avoid it being monkeyed with in the future. With your permission, I'd open this bug publicly and let it be strengthened in public patches.

Revision history for this message
Thierry Carrez (ttx) wrote :

Will open tomorrow unless someone raises a flag.

Thierry Carrez (ttx)
information type: Private Security → Public
Dolph Mathews (dolph)
Changed in keystone:
status: New → Triaged
importance: Undecided → Medium
Li Ma (nick-ma-z)
Changed in keystone:
assignee: nobody → Li Ma (nick-ma-b)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/43322

Li Ma (nick-ma-z)
Changed in keystone:
assignee: Li Ma (nick-ma-b) → nobody
Tom Fifield (fifieldt)
Changed in keystone:
status: In Progress → Confirmed
Revision history for this message
David Stanek (dstanek) wrote :

How should we proceed here? The patch submitted for this just hard codes the value of PASSLIB_MAX_PASSWORD_SIZE to 4096. Is that the correct thing to do or should we allow it to be configured?

If it can be configured do we need to have boundaries we can validate against (like a lower bounds of 1024 and and upper bounds of 16384)?

Revision history for this message
Dolph Mathews (dolph) wrote :

I would assume it should be end-user configurable (which it is today), but that seems to be completely at odds with the bug report. I can't really think of a simpler solution than the one proposed above; I'd appreciate feedback from Grant Murphy on the patch itself.

Revision history for this message
Grant Murphy (gmurphy) wrote :

So passlib defines the maximum password size as -

MAX_PASSWORD_SIZE = int(os.environ.get("PASSLIB_MAX_PASSWORD_SIZE") or 4096)

In this situation -

import passlib.utils
if CONF.identity.max_password_length > passlib.utils.MAX_PASSWORD_SIZE:
   # we might have problems.

One potential alternative to the proposed fix is to explicitly set the PASSLIB_MAX_PASSWORD_SIZE to the size defined in the configuration file. This would also act as a failsafe for any cases where max password length checks were missed.

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

Instead of returning HTTP 500 (ISE), the simplest fix is to just return HTTP 400. Lets be fair, if a deployer configures a longer maxium password than passlib can handle, it's either a 500 or a 400. In this case we can determine what the correct size would be and we should raise up a 400 Bad Request.

This is an edge case, but handling it elegantly is better than letting it just fail in an ugly way.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/98296

Changed in keystone:
assignee: nobody → Morgan Fainberg (mdrnstm)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on keystone (master)

Change abandoned by Morgan Fainberg (<email address hidden>) on branch: master
Review: https://review.openstack.org/98296
Reason: Based upon discussions with David Stanek, This should just be setting a max in oslo.config which is waiting for a fix to be released.

Changed in keystone:
status: In Progress → Triaged
assignee: Morgan Fainberg (mdrnstm) → nobody
Changed in keystone:
importance: Medium → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/217449

Changed in keystone:
assignee: nobody → Eric Brown (ericwb)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/217449
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=a7235fc0511c643a8441efd3d21fc334535066e2
Submitter: Jenkins
Branch: master

commit a7235fc0511c643a8441efd3d21fc334535066e2
Author: Eric Brown <email address hidden>
Date: Wed Aug 26 17:38:04 2015 -0700

    Set max on max_password_length to passlib max

    With this patch if someone overrides the PASSLIB_MAX_PASSWORD_SIZE
    environment variable, keystone will fail to start with a config
    error instead of a passlib.exc.PasswordSizeError when creating
    a user.

    Change-Id: Ic59a7964d8044ba3ab7cb6539fecca1d190dbbcc
    Closes-Bug: #1175905

Changed in keystone:
status: In Progress → Fix Committed
Changed in keystone:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: liberty-3 → 8.0.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.