Repository navigation
Conversation
Prateep07
left a comment
There was a problem hiding this comment.
The source allowlist and redacted pickle behavior address the ordinary-string case. One blocker remains before merge.
Change needed
A str subclass can still leak data through its pickle state. isinstance(source, str) accepts subclasses, and the allowlist branch returns the original source object when its value matches a safe label. A subclass’s custom pickle state can therefore include the secret. Please return a canonical built-in label (such as "env") instead of self.source, and add a regression test that confirms a subclass’s attached secret is absent from the pickle.
…eak state __reduce__ returned self.source when it matched a safe label, so a str subclass could carry a secret in its own pickle state. Now it emits a built-in label chosen with str.__eq__, which ignores subclass overrides.
|
@Prateep07 thanks, good catch. Fixed in
Two regression tests, both failing on the previous commit:
Full suite passes (884). Could you take another look? |
Prateep07
left a comment
There was a problem hiding this comment.
LGTM. The follow-up safely serializes canonical source labels, closing the str subclass pickle-state leak. Regression tests cover both subclass state and overridden equality, and the secret-value test suite passes (47 tests).
LGTM. The follow-up safely serializes canonical source labels, closing the str subclass pickle-state leak. Regression tests cover both subclass state and overridden equality, and the secret-value test suite passes (47 tests).
Follow-up to #93, fixing the two bugs from manish-wekan's review that were still on
develop. The third point (thecapture_localstest on Python 3.12) was already fixed ondevelop.Fixes
source=.__reduce__wrotesourceinto the pickle as is. NowSecretValue(value, source=...)raisesValueErrorif the source contains the secret, and pickles only carry one of the known labels (env,config,explicit); anything else is written ascustom.token_introspection_client_secret or os.environ.get(...)quietly replaced it.OAuthServicenow treats anySecretValueas "given", so unwrapping it raises instead of using the environment value. The same truthiness check was fixed in the introspection Basic-auth branch and inbuild_registration_response.Tests
Five new tests in
tests/test_secret_value.py. Three of them fail on currentdevelopand pass with this change (source rejected, custom source never pickled, redacted secret not replaced by the environment). The OAuth fallback to the environment when no secret is given still works. Full suite: 882 passed, 16 skipped locally.