fix(security): [CWE-613] enforce session validation#7
Draft
WilliamNHarvey wants to merge 2 commits into
Draft
Conversation
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.
Security Fix: CWE-613 — CookieSessionManager.Current does not enforce Session.Validate
Summary
Vulnerability Description
The
Sessioninterface declaredValidate(*http.Request) error, butCookieSessionManager.Currentonly decrypted and decoded the cookie throughSecureCookieManager.Get. It returned that decrypt/decode error directly and never invoked the validation hook. Consumers expectingCurrentto enforce expiration, revocation, request binding, or other session validity checks could accept validly encrypted but invalid sessions.Proof of Exploit
The proof harness seeded a valid encrypted session whose
Validatemethod always returned an error and incremented a counter.CookieSessionManager.Currentreturnednil, decoded the session, and left the validation counter at zero. Runtime startup was intentionally disabled for this static Go library; the issue is source-confirmable because the missing call was in the deterministic library control flow.Data Flow
Request cookie ->
CookieSessionManager.Current->SecureCookieManager.Getdecrypts and decodes into the caller-providedSession->Currentreturned without callingsess.Validate(req)-> invalid session state could be accepted by the caller.Changes Made
CookieSessionManager.Currentnow returns decrypt/decode errors first and callssess.Validate(req)after a successful decode. Regression tests cover both failing validation and successful validation, including that decoded session data is still available.Before / After
Before:
After:
HIPAA / PII Impact Assessment
This fix strengthens session validity enforcement for consuming services that may gate PHI/PII access through cookie-backed sessions. It does not log, expose, or store patient data.
Testing
go test -v ./...go vet ./...passedQA
This repository is a backend Go library/package with no browser, admin UI, or running service surface. Manual validation is local/API-level:
go test -v ./....TestCookieSessionManagerCurrentEnforcesSessionValidatereturns the validation error and records oneValidatecall.TestCookieSessionManagerCurrentReturnsNilWhenSessionValidatesstill returns successfully when validation passes.Reviewers
Ready-for-review PRs request
@doximity/security_guild_reviewers(AppSec) plusCODEOWNERS for the changed paths. Draft PRs intentionally defer security-guild
review requests until the PR is validated and marked ready. Both must approve
before merge.
This PR was auto-generated by the security-auditor agent.
The "Agent run cost" block is appended to this description automatically after
the audit run completes.