Skip to content

fix(open-sse): write Adobe Firefly session tokens and cookie jars with 0700/0600 perms (#12572) - #13242

Merged
diegosouzapw merged 1 commit into
release/v3.8.51from
fix/12572-firefly-perms
Sep 12, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.51from
fix/12572-firefly-perms

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Closes #12572

Root cause

open-sse/services/adobeFireflySession.ts and open-sse/services/adobeFireflyBrowserLogin.ts persist Adobe Firefly session state — including a live IMS Bearer JWT (accessToken) and the full Adobe cookie jar — to disk via mkdirSync(dir, { recursive: true }) and writeFileSync(path, ..., "utf8") with no mode argument, so the directory/file inherit the process umask (0755/0644 typically) instead of the restrictive 0700/0600 pattern already established in this repo for the analogous case (src/lib/vncSession/service.ts::createProfileDir).

The Notion half of the original report is a confirmed false positive (notionThreadSessions.ts's ThreadSessionEntry never persists a cookie/token) and is intentionally out of scope, per the plan-file analysis.

Fix

  • Added a shared open-sse/utils/secureFileWrite.ts (ensureSecureDir / writeSecureFile) mirroring the vncSession/service.ts::createProfileDir pattern (mkdirSync(..., mode: 0o700) + chmodSync(..., 0o700) for dirs; writeFileSync(..., mode: 0o600) for files) so a future browser-login integration can't reintroduce the unhardened pattern.
  • adobeFireflySession.ts: sessionFilePath() directory creation, the markAdobeFireflyArpSuccess() disk-fallback write, and saveDiskSession() now go through the shared helper.
  • adobeFireflyBrowserLogin.ts: adobeBrowserCookieJarPath() directory creation and saveAdobeBrowserCookies() now go through the shared helper.

Regression test

tests/unit/adobe-firefly-session-file-perms.test.ts (TDD, reusing the plan-file's proven-red repro mechanics):

  • markAdobeFireflyArpSuccess() on a fresh DATA_DIR creates adobe-firefly-sessions/ at mode 0700.
  • ensureSecureDir() tightens an already-existing 0777 directory back to 0700.
  • writeSecureFile() writes files at mode 0600.

The plan-file's own repro (markAdobeFireflyArpSuccess on a fresh mkdtemp DATA_DIR) was already proven RED against the current release/v3.8.51 tip (910f58c): AssertionError: expected adobe-firefly-sessions dir to be 0700 ..., got mode 775. The same call path is exercised by the new test suite above, now GREEN against the fix.

node --import tsx/esm --test tests/unit/adobe-firefly-session-file-perms.test.ts
✔ Adobe Firefly session dir/file are created with restrictive permissions (0700/0600)
✔ ensureSecureDir tightens an already-existing looser directory to 0700
✔ writeSecureFile writes files with 0600 permissions
ℹ tests 3, pass 3, fail 0

Gates run

  • node scripts/check/check-file-size.mjs → OK (no violations attributable to changed files)
  • node scripts/check/check-complexity.mjs → OK — 2798 violations (baseline 3218)
  • node scripts/check/check-cognitive-complexity.mjs → OK — 1265 violations (baseline 1437)
  • npm run typecheck:core → exit 0
  • npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files> → clean
  • New regression test: 3/3 pass
  • Existing Adobe Firefly test suites (adobe-firefly.test.ts, adobe-firefly-browser-login.test.ts, adobe-firefly-security.test.ts): 68/68 pass, unaffected

Scope

Out of scope per the plan-file (maintainer-confirmed): notionThreadSessions.ts (false positive, no credential fields persisted) and src/lib/db/core.ts DATA_DIR hardening (related but separate, lower-priority gap).

⚠️ base-red inherited: #12732 — unit #12058, integration codex-cache, package-artifact, tarball-smoke, agent-skills-sync

…h 0700/0600 perms (#12572)

adobeFireflySession.ts and adobeFireflyBrowserLogin.ts persisted the IMS Bearer JWT and
full Adobe cookie jar to disk via mkdirSync/writeFileSync with no mode argument, so
directories and files inherited the process umask (0755/0644) instead of the 0700/0600
pattern already established by src/lib/vncSession/service.ts::createProfileDir.

Adds a shared open-sse/utils/secureFileWrite.ts (ensureSecureDir/writeSecureFile) used by
both Adobe modules, and applies it at every directory-creation and session/cookie-jar
write call site.
@diegosouzapw
diegosouzapw force-pushed the fix/12572-firefly-perms branch from bf5ba2b to 60931fc Compare September 10, 2026 17:00
@diegosouzapw
diegosouzapw merged commit d0b22dd into release/v3.8.51 Sep 12, 2026
15 of 21 checks passed
Githab-capibara added a commit to Githab-capibara/OmniRoute that referenced this pull request Sep 17, 2026
…h 0700/0600 perms (cheaper-inference#12572) (cheaper-inference#13242)

Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit.

Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them.

- ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on cheaper-inference#13243)
- `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline
- 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs
- `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for cheaper-inference#13278 and cheaper-inference#13276, annotated and landed on cheaper-inference#13243

⚠️ base-red inherited: cheaper-inference#12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…h 0700/0600 perms (cheaper-inference#12572) (cheaper-inference#13242)

Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit.

Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them.

- ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on cheaper-inference#13243)
- `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK
- complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline
- 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs
- `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for cheaper-inference#13278 and cheaper-inference#13276, annotated and landed on cheaper-inference#13243

⚠️ base-red inherited: cheaper-inference#12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
@diegosouzapw
diegosouzapw deleted the fix/12572-firefly-perms branch October 18, 2026 23:48
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.

fix(backend): Adobe Firefly session token and cookie jar written with default file permissions

1 participant