cloudfoundry / cloudfoundry/stratos

Session ids are sequential integers; plan the move to a non-guessable id

Open
#5,790 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
267
Forks
137
Avg merge
5h 14m
Merged PRs (30d)
77

Description

#5733 consolidated the three session stores into one, keeping the integer autoincrement primary key so the existing contracts stayed untouched. That key shape is now isolated behind one seam, which makes changing it a bounded piece of work — this issue tracks doing so.

Why change it

Sequential ids are predictable. The securecookie HMAC means a bare id is not enough to forge a cookie, so this is defense-in-depth rather than a live hole — but the raw id travels further than the cookie:

  • the Kubernetes terminal writes it into a pod annotation, readable by anyone with pod read access in that namespace
  • session_data rows carry it as a plain string column

A non-guessable id removes the value of both exposures.

What the change touches

The integer shape is load-bearing in exactly three places (documented in the sessionstore package comment):

  • api.SessionDataStore.IsValidSession(id int)
  • the session_data join: CAST(id AS varchar) against the sessions table
  • plugins/kubernetes/terminal/cleanup.go — annotation round-trip via strconv.Atoi

Sketch

Generate a random id (128-bit, hex or base64url) in the store at insert; the id column becomes a string type with a unique index; the three call sites move from int to string — the CAST disappears rather than moves. Migration recreates the table, so the cost is the same one-time sign-out #5733 already established, and kube-terminal pods annotated with old ids are reaped by the existing cleanup.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the sessionstore package comment and trace api.SessionDataStore.IsValidSession, the session_data join, and plugins/kubernetes/terminal/cleanup.go. Check the migration approach established by #5733 and verify the insert, annotation round-trip, and cleanup paths. Done means session ids are non-guessable strings, the CAST and strconv.Atoi paths are removed, and old annotated ids are still reaped.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, databases, infrastructure, security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.