T09 · Insecure Skill Coding Practices
- Location
rules/server-after-nonblocking.md:44- Finding
Raw Session Credential Passed to an Unspecified Logging Pipeline
- Content
View full analysis
{ const userAgent = (await headers()).get('user-agent') || 'unknown' const sessionCookie = (await cookies()).get('session-id')?.value || 'anonymous' logUserAction({ sessionCookie, userAgent }) }) ``` ### Technical Analysis The recommended example reads the raw value of the `session-id` cookie and passes it to `logUserAction`. A session identifier is generally a bearer credential: anyone who obtains a valid value may be able to impersonate the associated user until the session expires or is revoked. The destination and security properties of `logUserAction` are unspecified. It could write to local logs, a shared observability platform, or an external analytics service. Logging infrastructure commonly has broader access controls, longer retention periods, and more downstream integrations than the authentication system. Consequently, transmitting the raw session identifier into that pipeline violates data-minimization and least-privilege principles. Using `after()` does not mitigate this exposure. It only changes when the logging operation runs. ### Attack Path 1. An agent or developer applies the recommended example in a Next.js application. 2. An authenticated request supplies a valid `session-id` cookie. 3. The server reads the raw session credential and passes it to `logUserAction`. 4. The logging implementation stores or forwards the credential to a log aggregation or analytics system. 5. A malicious insider, compromised integration, exposed dashboard, or attacker with log access retrieves the session value. 6. If the session remains valid and is not bound to additional client properties, the attacker places the stolen value in a request cookie and impersonates the victim. ### Impact Assessment Successf ...[truncated 474 chars]- Remediation
View remediation
