aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-07 22:59:34 -0700
committerAdam Soltys <[email protected]>2026-08-07 23:29:25 -0700
commitf9e8638b2443ebf2da2e11eb12d1a8d60bf7c9d6 (patch)
treed1aa51e25386e364bcd918b098b61e2098479c59 /routes
parentd513ab75131bfaa16b1f0820d0fb18ad9e7f6ab1 (diff)
downloadcoinos-server-f9e8638b2443ebf2da2e11eb12d1a8d60bf7c9d6.tar.gz
coinos-server-f9e8638b2443ebf2da2e11eb12d1a8d60bf7c9d6.zip
logging: redact auth headers; set cookie flags on session token (S5)
The request logger persisted full req.headers to the "req" log, including the Authorization bearer token and the token cookie — both non-expiring JWTs, so log-read access became account takeover. Redact the authorization and cookie headers. Also set httpOnly/secure/sameSite on the token cookie so it isn't readable by injected JS or sent over plaintext HTTP. (Revocation is already handled by the evicted set.) Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'routes')
-rw-r--r--routes/users.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/routes/users.ts b/routes/users.ts
index eafcd74a..ed2d3861 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -454,7 +454,13 @@ export default {
const payload = { id: user.id };
const token = jwt.sign(payload, config.jwt);
- res.cookie("token", token, { expires: new Date(Date.now() + 432000000) });
+ res.cookie("token", token, {
+ expires: new Date(Date.now() + 432000000),
+ path: "/",
+ httpOnly: true,
+ secure: true,
+ sameSite: "lax",
+ });
user = pick(user, whitelist);
res.send({ user, token });
} catch (e) {
@@ -514,7 +520,13 @@ export default {
const payload = { id: user.id };
const token = jwt.sign(payload, config.jwt);
- res.cookie("token", token, { expires: new Date(Date.now() + 432000000) });
+ res.cookie("token", token, {
+ expires: new Date(Date.now() + 432000000),
+ path: "/",
+ httpOnly: true,
+ secure: true,
+ sameSite: "lax",
+ });
user = pick(user, whitelist);
res.send({ user, token });
} catch (e) {