Roundup Tracker - Issues

Issue 2551438

classification
password.py Password(encrypted=...) accepts random strings.
Type: Severity: normal
Components: API Versions:
process
Status: new
:
: : rouilj
Priority: : patch

Created on 2026-11-10 20:24 by rouilj, last changed 2026-11-15 23:51 by rouilj.

Files
File name Uploaded Description Edit Remove
encrypted_should_not_accept_plaintext_paswords.patch rouilj, 2026-11-15 23:51
Messages
msg8580 Author: [hidden] (rouilj) Date: 2026-11-10 20:24
When retrieving a Password property via rest API, the value is intentionally obscured.

If that value is round-tripped back to the rest API, the obscured value
looks like it is set as the password. This is bad since the obscured
phrase is predictable.

One way to handle this is to block read access to any password field in the schema
permissions.

For example using:

 user = db.security.addPermission(name='View', klass='user', check=own_record,
    properties=('username', 'address', 'realname', 'phone',         
        'organisation', 'alternate_addresses', 'queries', 'timezone'),          
    description="User is allowed to view their own user details")

in schema.py to replace the user View permission should prevent a GET rest request with
query params that include '@verbose=0&@protected=true' from including the password
property in the returned response.

(The 'password' property should be left in the user Edit permission definition so a
password can be changed remotely.)

I was expecting the password.py::Password:__init__ to fail when processing the obscured
phrase. The obscured phrase is passed via the 'encrypted' parameter to __init__.
Then __init__ parses the encrypted property splitting off the encryption algorithm,
params (salt) etc.

However if it fails, it takes the encrypted value and uses it as a plain text value that
it encrypts and returns to the caller. I think this a bug in the Password module. I claim
it should not accept an invalid encrypted value.  Note that "encrypted" can be '{plaintext}my plaintext password' but must include the encryption format label.

This is kind of an edge case as it involves using the password property via rest.
But it does stop round tripping the rest item retrieved by a GET request to the rest API
with '@verbose=0&@protected=true' query params.

See also: issue 2551437 to clean up handling of reserved properties when round-tripping
API responses.
msg8581 Author: [hidden] (rouilj) Date: 2026-11-10 21:08
One addition. In the properties example for view properties, you need to include the 'activity' property. Otherwise the collision detection that uses the last activity property is set
to '[hidden]' and you can't submit any web form as hidden is not a valid date.
msg8585 Author: [hidden] (rouilj) Date: 2026-11-15 23:51
The invalid change to password when submitting placeholder text over REST is
solved in changeset:   8877:9f3f79cb732f.

However, I claim using encrypted and plain arguments should require a value
of the proper type.

It looks like encrypted= is used in hyperdb.py::Password.from_raw().
I am not sure how from_raw() would get invoked with a packed encrypted value.

Returning password placeholders to the front end came after the
from_raw and unpack code was written from what I can tell. So maybe
the fallback to encrypting something that fails unpacking isn't needed?

The signature password.py::Password.__init__(self, plaintext=None, ....) means
Password("Foo") sets plain password to Foo. It looks like all calls that use
encrypted set it explicitly as a keyword argument.

I have attached a patch that modifies from_raw() and password.py:unpack()
to raise an exception up the stack that gets caught in the from_raw caller
and omits the parameter. It works but seem icky.

Also  thought by pushing it down to the hyperdb level, more code paths
(like the cgi action to update a user) would go though this path. But it
appears that hyperdb::Password.from_raw is only called from the REST interface
when updating a Password.
History
Date User Action Args
2026-11-15 23:51:51rouiljsetfiles: + encrypted_should_not_accept_plaintext_paswords.patch
keywords: + patch
messages: + msg8585
2026-11-10 21:08:21rouiljsetmessages: + msg8581
2026-11-10 20:24:13rouiljcreate