fix(cnr): mask the session id in the secured POST body - #327
Merged
KaiSchwarz-cnic merged 1 commit intoAug 26, 2026
Conversation
getPOSTDataParams() masked s_pw but wrote s_sessionid in clear, so the body built for debug logging carried a working credential. A session id is not a lesser credential than the password but an alternative to it: setSession() clears the password, because the newer of the two is authoritative on the wire. The gap therefore opened exactly where it mattered — on the persistent-session path there is no password left to mask, and what the debug record contained was login plus session, everything needed to authenticate. IBS/MONIKER are unaffected; they have no session parameter. The new test asserts with a login present, which is the shape the fix is about, and pins the absence of the raw value rather than only the expected string. The existing masked-path tests set credentials rather than a session, so none of them covered this and none of them change. The three tests that do assert an unmasked s_sessionid call getPOSTData() on the default unmasked path, which is the request body and still has to carry the real value.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #327 +/- ##
=========================================
Coverage 99.90% 99.90%
- Complexity 469 470 +1
=========================================
Files 32 32
Lines 1065 1065
=========================================
Hits 1064 1064
Misses 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
🎉 This PR is included in version 33.0.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while setting up P8 of RSRMID-2994, and it doubles as that ticket's release trigger — a
fixtouchingsrc/is what makes semantic-release cut a version, which is what P8 needs in order to verify the release push now goes out over the deploy key.The change stands on its own merits, though. It is not a contrived commit.
The defect
CNR\SocketConfig::getPOSTDataParams()maskeds_pwbut wrotes_sessionidin clear:$maskSecrets = trueis the body built for debug logging. So a debug record could carry a working credential.Why it matters more than it looks
A session id is not a lesser credential than the password but an alternative to it.
setSession()says so itself, and enforces it:So the gap opened precisely where it mattered. On the persistent-session path there is no password left to mask, and what the masked body contained was
s_login+s_sessionid— everything needed to authenticate. Masking the password while logging the session defeated the masking on the one path where masking was the only thing left.Scope
IBS/MONIKERare unaffected — they have no session parameter.Tests
testGetPostDataSecuredMasksSession()asserts with a login present, which is the shape the fix is about, and pins the absence of the raw value rather than only the expected string.No existing test changes:
ClientTest::testGetPostDataSecured,testGetPostDataSecuredMasksAuth,CNR\LoggerTest) set credentials rather than a session, so none of them covered thiss_sessionidcallgetPOSTData()on the default unmasked path — that is the real request body and still has to carry the real valueI could not run the suite locally: the workspace devcontainer installs no language runtimes by design, so there is no PHP here. Static checks I did make:
CommandRedactorwas already imported, the new line is shorter than thes_pwline beside it, and both sides of the assertion go throughhttp_build_query.Note
If you would rather this had its own issue rather than riding on RSRMID-2994's branch prefix, say so and I will move it.
🤖 Generated with Claude Code