You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "JasonBuildAI (via GitHub)" <gi...@apache.org> on 2026/10/11 11:56:24 UTC

[I] bug(core): fine-grained GitHub PATs (github_pat_) pass both shared redactors unmasked [maka]

JasonBuildAI opened a new issue, #6061:
URL: https://github.com/apache/maka/issues/6061

   ### What happened
   
   Both shared secret redactors mask every classic GitHub token family but not fine-grained PATs (`github_pat_...`):
   
   - `redactSecrets` in `packages/core/src/redaction.ts` (line 74: `gh[pousr]_[0-9A-Za-z_]{20,}`), used by the PTY screen collector, the diagnostic log, and MCP secret handling.
   - the display redactor in `packages/core/src/display-redaction.ts` (line 102: `gh[opusr]_[A-Za-z0-9]{30,}`), the single source for the Desktop quiet panel and the TUI (`packages/ui/src/redact.ts`).
   
   `github_pat_...` is the fine-grained PAT format GitHub has issued by default since October 2022, and it is the format Maka itself imports as a GitHub Copilot credential: `isSupportedGitHubCopilotAccountToken` (`packages/runtime/src/subscription-credentials.ts:511`) accepts exactly `gho_`, `ghu_`, and `github_pat_` (classic `ghp_` is refused with a dedicated error).
   
   For a user who has a fine-grained PAT in the environment Maka reads (`COPILOT_GITHUB_TOKEN`, `GH_TOKEN`, `GITHUB_TOKEN` in `apps/desktop/src/main/oauth/github-copilot-local-credential.ts`), or who prints one inside a command:
   
   - Session shells inherit the Host environment (`packages/runtime/src/shell-run-manager.ts:788`), so `env`, `printenv`, `gh auth token`, or any command that dumps its environment puts the raw token into tool output.
   - `packages/runtime/src/pty-screen-collector.ts:501` uses `redactSecrets(line) !== line` as its whole-line suppression test, so the line is neither redacted nor suppressed and reaches the model and the transcript.
   - The quiet-panel/TUI preview (`packages/core/src/tool-quiet-preview.ts`) renders it in plain text, including text users screenshot or paste into bug reports.
   - The diagnostic log (`packages/core/src/diagnostic-log.ts:58`) stores it, so exported diagnostics bundles carry a live repository credential.
   - MCP secret scrubbing uses `isPatternSecret` (`packages/core/src/mcp-secrets.ts:93`) as the only signal for free-form positions, so `--custom=github_pat_...` or a query value under a harmless key is not recognized as credential material.
   
   Measured against the built `@maka/core` at `fa26868b1d223acc833089e94b6834188926f49c` (fake tokens, repeated characters):
   
   ```
   family                      | core redactSecrets        | display redactSecrets     | pty line suppression
   github_pat_ (fine-grained)  | LEAKS UNCHANGED           | LEAKS UNCHANGED           | does NOT suppress
   ghp_ (classic PAT)          | [redacted]                | <redacted>                | suppresses
   gho_ (OAuth)                | [redacted]                | <redacted>                | suppresses
   ghu_ (user-to-server)       | [redacted]                | <redacted>                | suppresses
   ghs_ (server-to-server)     | [redacted]                | <redacted>                | suppresses
   ghr_ (refresh)              | [redacted]                | <redacted>                | suppresses
   isPatternSecret(github_pat_): false
   isPatternSecret(ghp_):        true
   ```
   
   Expected: the fine-grained family is masked on the same terms as the five classic families above.
   
   ### How to reproduce
   
   1. `npm ci && npm run build`
   2. Save and run this script (`node repro.mjs`); it imports the built redactors directly:
   
   ```js
   import { redactSecrets as coreRedactor } from './packages/core/dist/redaction.js';
   import { redactSecrets as displayRedactor } from './packages/core/dist/display-redaction.js';
   import { isPatternSecret } from './packages/core/dist/mcp-secrets.js';
   
   const fineGrained = 'github_pat_11' + 'a'.repeat(80); // fake
   console.log('core:   ', coreRedactor(fineGrained) === fineGrained ? 'LEAKS' : 'masked');
   console.log('display:', displayRedactor(fineGrained) === fineGrained ? 'LEAKS' : 'masked');
   console.log('control:', coreRedactor('ghp_' + 'a'.repeat(36)) === 'ghp_' + 'a'.repeat(36) ? 'LEAKS' : 'masked');
   console.log('mcp:    ', isPatternSecret(fineGrained));
   ```
   
   Actual output: `core: LEAKS`, `display: LEAKS`, `control: masked`, `mcp: false`.
   
   ### Environment
   
   - Maka version or commit: `fa26868b1d223acc833089e94b6834188926f49c` (`main`)
   - OS and version: Windows 11 24H2; the defect is pure string matching, so any OS reproduces it
   - Surface: `@maka/core` shared redactors (Desktop, TUI, Runtime Host, diagnostics)
   - Node.js version, if running from source: 24.21.0
   
   ### Logs, screenshots, or additional context
   
   - `SECURITY.md` section 2.4 lists `redactSecrets()` as a heuristic the project ships but does not treat as a boundary, and says reports that limit it "are welcome as ordinary issues, not security advisories". Filing accordingly.
   - Precedent for single-family redaction fixes: #298, #2042, #3688, #4593 (fixed by #4597), #5433 (fixed by #5434).
   - Scope: one added alternative in each of the two pattern lists, plus tests; no new dependency and no behavioral change for any input the redactors already mask.
   
   AI assistance disclosure: measurements and drafting were produced with AI (Codex) at my request and under my direction; I reviewed the reproduction and the cited code paths.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] bug(core): fine-grained GitHub PATs (github_pat_) pass both shared redactors unmasked [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han closed issue #6061: bug(core): fine-grained GitHub PATs (github_pat_) pass both shared redactors unmasked
URL: https://github.com/apache/maka/issues/6061


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org