Title: [Medium][server] Session and CSRF cookies are not Secure by default · Issue #169 · bQuery/bQuery · GitHub
Open Graph Title: [Medium][server] Session and CSRF cookies are not Secure by default · Issue #169 · bQuery/bQuery
X Title: [Medium][server] Session and CSRF cookies are not Secure by default · Issue #169 · bQuery/bQuery
Description: Severity: 🟡 Medium (insecure default; direct credential-theft impact) Location Session cookie: src/server/session.ts:301-306 (and destroy path :336-343) CSRF secret cookie: src/server/csrf.ts:159-163 Description The session-id cookie def...
Open Graph Description: Severity: 🟡 Medium (insecure default; direct credential-theft impact) Location Session cookie: src/server/session.ts:301-306 (and destroy path :336-343) CSRF secret cookie: src/server/csrf.ts:159-1...
X Description: Severity: 🟡 Medium (insecure default; direct credential-theft impact) Location Session cookie: src/server/session.ts:301-306 (and destroy path :336-343) CSRF secret cookie: src/server/csrf.ts:159-1...
Opengraph URL: https://github.com/bQuery/bQuery/issues/169
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Medium][server] Session and CSRF cookies are not Secure by default","articleBody":"## Severity: 🟡 Medium (insecure default; direct credential-theft impact)\n\n## Location\n- Session cookie: [`src/server/session.ts:301-306`](../blob/main/src/server/session.ts#L301-L306) (and destroy path `:336-343`)\n- CSRF secret cookie: [`src/server/csrf.ts:159-163`](../blob/main/src/server/csrf.ts#L159-L163)\n\n## Description\nThe session-id cookie defaults to `{ httpOnly: true, sameSite: 'lax', path: '/' }` with **no `secure`**:\n```ts\nconst baseCookie: ServerCookieOptions = {\n httpOnly: true,\n sameSite: 'lax',\n path: '/',\n ...options.cookie,\n};\n```\nThe cookie holds the signed session id — the sole bearer credential for the session. On any deployment reachable over plain HTTP (mixed HTTP during redirect, or behind a misconfigured proxy), the cookie is transmitted in cleartext and can be captured by a network MITM, yielding full session hijack. `sameSite: 'lax'` does not compensate. The behaviour is documented (\"Set `secure: true` in production\"), but insecure-by-default for a session credential is a real trap for anyone who doesn't read the note.\n\nThe CSRF secret cookie (`csrf.ts`) has the same default (`{ sameSite: 'lax', path: '/' }`, no `secure`); in signed mode the token embeds the raw secret, so a MITM over HTTP can read it and forge matching tokens.\n\n## Suggested fix\nDefault `secure: true` and let users explicitly opt out for local HTTP dev, e.g. `secure: options.cookie?.secure ?? true`; or auto-enable `Secure` when the request/base URL is `https:`. Apply consistently to both the session and CSRF cookies. Consider promoting `__Host-` guidance from a doc note to a runtime default.\n\n---\n_Filed as part of a full-codebase security \u0026 correctness audit._\n","author":{"url":"https://github.com/JosunLP","@type":"Person","name":"JosunLP"},"datePublished":"2026-07-05T17:03:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/169/bQuery/issues/169"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fbc83805-2a0a-7c50-93da-4a39f10003a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC0E:11A717:159F4F2:1DEFAAB:6A4DF00C |
| html-safe-nonce | 096a3f6c04fc90c66c28f4a10a6e5a45031280fbd84e208f29f5c51643747ed1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzBFOjExQTcxNzoxNTlGNEYyOjFERUZBQUI6NkE0REYwMEMiLCJ2aXNpdG9yX2lkIjoiNjEzNDQwMTYzNjMxNzkxNzE5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 711c07cad75fa44161876f3d50d403e71742af219453591c350fdaf76b7b381e |
| hovercard-subject-tag | issue:4813694337 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/bQuery/bQuery/169/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc3afe1fee22e2e6c020a80ce4fc4456055d0a6fd1457dff12986a4343d5e2ce/bQuery/bQuery/issues/169 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc3afe1fee22e2e6c020a80ce4fc4456055d0a6fd1457dff12986a4343d5e2ce/bQuery/bQuery/issues/169 |
| og:image:alt | Severity: 🟡 Medium (insecure default; direct credential-theft impact) Location Session cookie: src/server/session.ts:301-306 (and destroy path :336-343) CSRF secret cookie: src/server/csrf.ts:159-1... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JosunLP |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/bQuery/bQuery git https://github.com/bQuery/bQuery.git |
| octolytics-dimension-user_id | 256381806 |
| octolytics-dimension-user_login | bQuery |
| octolytics-dimension-repository_id | 1139284244 |
| octolytics-dimension-repository_nwo | bQuery/bQuery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1139284244 |
| octolytics-dimension-repository_network_root_nwo | bQuery/bQuery |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f4bb89367ca678f057d79b1abc45d6675b1bd5b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width