Skip to content

security: untrack .tj/config.toml (removes leaked ingest_secret from repo) - #145

Merged
anilmurty merged 2 commits into
mainfrom
security/141-untrack-tj-config
Jun 18, 2026
Merged

anilmurty merged 2 commits into
mainfrom
security/141-untrack-tj-config

Conversation

@anilmurty

Copy link
Copy Markdown
Contributor

Addresses finding #6 (HIGH, security) in #141.

.tj/config.toml was committed at v0.2.0 (commit a9173b8) and contains a real ingest_secret. The file is publicly readable in the git repo (not in the PyPI wheel, but git is the exposure). .gitignore:43 already had .tj/ — that rule doesn't retroactively untrack already-committed files.

This PR runs git rm --cached .tj/config.toml (untracks; keeps the local working copy so existing installs keep running). Future git clones won't carry the file, so tj onboard works on fresh clones again.

Blast radius

The leaked value is an ingest_secret — the bearer token protecting POST /api/v1/spans on a local tj serve. It's per-install, network-only. Worst case: someone on the same network as a daemon configured with this exact secret could push fabricated spans to that daemon. No data exfil. Not a CVE.

What this PR does NOT do

  • The secret remains in git history and in published tags (v0.2.0 through v0.3.5). Rewriting that history would invalidate every release tag and break every fork; the cost outweighs the benefit given the limited blast radius.
  • Not a security advisory — see blast radius above.

Action for anyone who reused the secret

Generate a fresh value:

python3 -c "import secrets; print(secrets.token_hex(32))"

and update your local ~/.config/tj/config.toml and .tj/config.toml.

Test plan

  • Confirm .tj/config.toml is no longer in the index post-merge: git ls-files .tj/config.toml returns nothing.
  • Fresh clone of the repo does not contain the file.
  • Existing local working trees keep their .tj/config.toml so daemons continue running.

Reported by @ashwmu in #141 (finding #6).

🤖 Generated with Claude Code

Co-Authored-By: ashwmu [email protected]

anilmurty and others added 2 commits June 18, 2026 16:19
…repo)

`.tj/config.toml` was committed at v0.2.0 (a9173b8) and has been tracked
through every release since. The file contains a real `ingest_secret`
that is publicly readable in the git repo (not in the PyPI wheel —
`packages = ["tokenjam"]` excludes the workspace directory, but the git
exposure is the issue).

`.gitignore:43` already lists `.tj/` — that rule didn't retroactively
untrack the already-committed file. This removes the file from the index
while keeping the local working copy so existing installs keep running.

## Blast radius

The leaked value is an `ingest_secret`, the bearer token that protects
`POST /api/v1/spans` on a local `tj serve`. It's per-install, network-only.
Worst case: someone on the same network as a daemon configured with this
exact secret could push fabricated spans to that daemon. There's no
data-exfil path; the secret doesn't unlock anything beyond span ingest.

## What this PR does
- `git rm --cached .tj/config.toml` (file removed from index, kept locally)
- Future `git clone` will not carry the file → `tj onboard` works on fresh clones again

## What this PR does NOT do
- The secret remains in git history and in published tags (v0.2.0 through v0.3.5).
  Rewriting that history would invalidate every release tag and break every
  fork; the cost outweighs the benefit given the limited blast radius above.
- This is not a CVE. The secret was the project author's local dev install
  secret, not a customer credential.

## Action required of anyone who reused this secret
If you happened to copy the committed config (unlikely but possible),
generate a fresh value: `python3 -c "import secrets; print(secrets.token_hex(32))"`
and update your local `~/.config/tj/config.toml` and `.tj/config.toml`.

Reported by @ashwmu in #141 (finding #6).

Co-Authored-By: ashwmu <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@anilmurty
anilmurty merged commit e1c8cbd into main Jun 18, 2026
4 checks passed
@anilmurty
anilmurty deleted the security/141-untrack-tj-config branch June 18, 2026 23:45
HoomanDgtl pushed a commit to HoomanDigital/tokenjam that referenced this pull request Jun 20, 2026
Two prevention measures distilled from this week's repeated near-misses:

1. CLAUDE.md gets a new "Working with concurrent agents" section right
   after Build & Development. It explains the worktree pattern, the
   collision symptom (a commit on a branch you didn't intend, caused by
   another agent's HEAD being the checked-out one), and the safe
   recovery (rebase off, don't force-push).

2. New Critical Rule 20 documenting that `.tj/config.toml` is untracked
   and must stay that way (live per-install ingest_secret, regenerated
   at runtime).

3. New CI test `tests/unit/test_no_tracked_dev_secrets.py` that fails
   loud with a fix command if anyone re-stages `.tj/config.toml`. Cheap
   guard against the v0.2.0 → v0.3.5 leak (PR Metabuilder-Labs#145 + issue Metabuilder-Labs#141 finding
   Metabuilder-Labs#6) recurring.

Reported by @ashwmu in Metabuilder-Labs#141 finding Metabuilder-Labs#6. The collision pattern surfaced
across the Lens UI work, the Reuse analyzer, and the Metabuilder-Labs#141 triage — see
the "Working with concurrent agents" section for the recovery playbook.

Co-Authored-By: ashwmu <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
HoomanDgtl pushed a commit to HoomanDigital/tokenjam that referenced this pull request Jun 20, 2026
TokenJam v0.4.0 — major release. Significant new product surface beyond
the 0.3.x patch cadence:

- TokenJam Lens UI rebrand: Overview triage front door, Optimize detail
  tab, real charts (uPlot, vendored offline), URL-state filters,
  plan-tier-aware framing on all dollar-bearing surfaces.
- Reuse — the 5th analyzer + `tj report --reuse` artifact export
  (HTML + Markdown skeleton sidecars).
- New `core/framing.py` — single source of truth for plan-tier
  rendering, consumed by both CLI and REST API.
- `estimated_recoverable_usd` contract on every savings analyzer
  (Metabuilder-Labs#111), normalized to a single time basis (Metabuilder-Labs#122) so Overview tiles
  are directly comparable.
- `cache_write_tokens` surfaced through DB → API → CLI → UI (Metabuilder-Labs#149) —
  fixed the ~91% hidden cost driver on cache-heavy workloads.
- Security: `.tj/config.toml` untracked (Metabuilder-Labs#145) + CI guard
  (`tests/unit/test_no_tracked_dev_secrets.py`).
- 17 v0.3.5 post-release findings closed (Metabuilder-Labs#141) + 5 Lens UI bug rounds
  (Metabuilder-Labs#126-Metabuilder-Labs#136) + onboard `--plan` honored on plain path (Metabuilder-Labs#148).

## Also in this commit

**Step 6 in the pre-release checklist** is corrected to match real
behavior: `tj report --reuse` with the daemon running exits with the
"needs direct database access" hint (workaround: `tj stop`). Long-term
fix tracked as Metabuilder-Labs#154 for v0.4.1.

**Test outputs committed.** `tests/results/` was gitignored; flipping
it so per-release pre-release test logs ship as part of the repo for
historical reference. Two v0.4.0 result logs included: the first pass
(which surfaced two bugs fixed in PR Metabuilder-Labs#153) and the clean re-run after
those fixes landed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant