BitBootcampBitBootcamp ← all explainers 🔄 Review ⚙ Settings

Drill 42 — The Notebook on GitHub

Theme: Security & Trust Boundaries · Format: 20-min drill · Difficulty: intro

The story

A data scientist pushes an analysis notebook to a public repo — a cleaned-up version of internal work, for a blog post. Cell 2 contains a live database credential, pasted months ago "just to get it working." Automated scanners (the attackers' kind) find it within hours. The rotation scramble reveals the deeper problem: that credential is shared by four services, and nobody is sure what breaks if it rotates.

⏸ Stop here and ask the room: the leak is the small problem. Name the big one.

Run it — facilitator script

Timing for a 20-minute session: 2 min story · 10 min staged questions · 3 min reveal · 5 min transfer.

Why couldn't they rotate immediately?

What's the blast radius of any one credential we hold?

What catches the next pasted secret before it ships?

The reveal

Rotation takes three days of careful coordination — three days with a known-leaked credential live in production — because the key was load-bearing in ways nobody had mapped.

Why this happens — the mechanics

Secrets sprawl because the moment of pasting is always locally rational. The data scientist needed the connection to work, the secret manager felt like friction, and "temporary" has no enforcement mechanism — so the credential stayed, invisible, while the notebook's context changed around it. Code moves — between repos, between laptops, between visibility levels — and anything embedded in it moves too. The paste isn't an anomaly; it's the default outcome of making the wrong path the easy one.

Rotation stays scary for a structural reason: shared credentials accumulate consumers silently. Every new service that authenticates with an existing key adds a dependency nobody records — there is no pull request that says "service four now depends on this key." By the time rotation matters, the dependency graph exists only in production behavior, and the only way to read it is to break it.

Discovery, meanwhile, is asymmetric. Attackers run continuous automated scanning against every public commit; the interval between push and exploitation is measured in minutes to hours. Your side of the race — a human noticing, a quarterly review — is measured in months. Any defense that depends on winning that race by attention loses; the control has to fire before the push completes, or the leak has to not matter.

Diagrams

Problem — how the failure unfolds:

sequenceDiagram
    autonumber
    participant DS as Data scientist
    participant GH as Notebook on GitHub
    participant SC as Attacker scanners
    participant SV as Four services
    DS->>GH: Pastes live database<br/>credential in cell 2 (silent)
    Note over SV: Months pass - key quietly<br/>load-bearing (silent)
    DS->>GH: Cleans up notebook, pushes<br/>to a public repo
    SC->>GH: Automated scanners find<br/>the key within hours
    Note over DS: Rotation scramble begins
    DS--xSV: Key shared by four services -<br/>nobody knows what breaks
    Note over DS,SV: 3 days of coordination -<br/>known-leaked credential<br/>stays live

Solution — where the guardrails go:

flowchart TD
    A["Credential needed for analysis"] --> B["Fetched from a secret<br/>manager — never pasted<br/>into code"]
    B --> C["Short-lived credential,<br/>scoped to one service"]
    D["Notebook pushed to any repo"] --> E["Pre-commit and CI secret<br/>scanning"]
    E -.-> AL["Push blocked, owner<br/>alerted in minutes"]
    C --> F["Any single leak is small:<br/>one service, hours of<br/>validity"]
    F --> G["Rotation rehearsed as a<br/>routine, boring operation"]
    AL -.-> G

What good looks like

The lesson

The real vulnerability wasn't the paste; it was that rotation wasn't routine. Secrets belong in managers (never in code or notebooks), pre-commit and CI scanning catch the inevitable slips, and credentials should be short-lived and service-scoped so that any single leak is small and any rotation is boring. If rotating a credential is scary, that's the finding.

Named concepts: secret scanning, short-lived credentials, credential scoping, rotation as routine operation.

Real-world echoes

Transfer

Pick any production credential: if it leaked right now, how long until it's rotated and what breaks meanwhile? If the answer involves a meeting, we have work to do.

Make it a ticket: Take the credential the room just picked, list every consumer from its usage logs, and schedule its rotation as a rehearsed drill this sprint — the deliverable is a measured time-to-rotate, written down next to the target.

Related