[PR Title / Module Name]
PR #XXX
Author: @username
Date: YYYY-MM-DD
TL;DR: [One sentence summary]
Risk Map
🟢 safe src/utils.ts
🟡 worth a look src/auth.ts
🔴 needs attention src/payment.ts
Code Changes
function verifyToken(token: string) {
- return jwt.verify(token, SECRET);
+ const decoded = jwt.verify(token, SECRET);
+ if (!decoded.sub) throw new AuthError('Invalid token');
+ return decoded;
}
Behavior Change
Before
- Token without 'sub' claim accepted
- No validation on decoded payload
After
- Token must have 'sub' claim
- Explicit AuthError on invalid token
Request Path
[Browser]
→
[Load Balancer]
→
[API /api/session]
→
[verifyToken]
→
[SessionStore]
Call Stack Walkthrough
1
src/app/providers/AuthProvider.tsx:22-48
On mount, the React provider issues GET /api/session to check auth status.
show source
useEffect(() => {
fetch('/api/session')
.then(r => r.json())
.then(setUser);
}, []);
2
src/middleware/auth.ts:14-31
⚠️ TRUST BOUNDARY
This is the trust boundary. verifyToken reads the signed cookie and validates it.
show source
function verifyToken(token: string) {
const decoded = jwt.verify(token, SECRET);
if (!decoded.sub) throw new AuthError('Invalid token');
return decoded;
}
Trust Boundary
⚠️ Trust Boundary
Everything below verifyToken is trusted. Everything above it is not.
This is where the JWT token is validated against the secret. Any tampering here compromises the entire session.