google-gemini / google-gemini/gemini-cli

sanitizeToolArgs redacts non-secret keys like max_tokens and author via substring match

Open Beginner friendly
#29,144 6 comments 0 reactions 0 assignees View on GitHub
area/agent kind/bug priority/p2 status/bot-triaged status/need-information
Dominant language
TypeScript
Stars
107k
Forks
14.6k
Avg merge
2d 3h
Merged PRs (30d)
45

Description

### What happened?

`sanitizeToolArgs()` decides a tool-arg key is sensitive with substring `.includes()` after stripping `-`/`_`. That over-matches.

packages/core/src/utils/agent-sanitization-utils.ts:

```ts
const keyNormalized = decodedKey.toLowerCase().replace(/[-_]/g, '');
const isSensitive = SENSITIVE_KEY_PATTERNS.some((pattern) =>
keyNormalized.includes(pattern.replace(/[-_]/g, '')),
);
```
SENSITIVE_KEY_PATTERNS includes token and auth, so:

max_tokens → maxtokens.includes(token) → [REDACTED]
tokenizer → [REDACTED]
author → author.includes(auth) → [REDACTED]
authentication → [REDACTED]
These args are shown in subagent/browser activity via sanitizeToolArgs(...). Real parameters disappear; the user/model see [REDACTED] instead of 8192 or an author name.

Existing tests in agent-sanitization-utils.test.ts only cover exact keys (password, api_key), not false positives.

Repro (unit-level):
```ts
sanitizeToolArgs({ max_tokens: 8192, author: 'alice', model: 'gemini-pro' })
// actual: { max_tokens: '[REDACTED]', author: '[REDACTED]', model: 'gemini-pro' }
// expected: { max_tokens: 8192, author: 'alice', model: 'gemini-pro' }

```

### What did you expect to happen?

Only keys that are actually secrets should be redacted (password, api_key, access_token, …).

max_tokens, author, and similar non-secret keys should pass through unchanged.

Matching should be exact (or token-boundary) on the normalized key, not substring .includes().

### Client information

Client Information

Run `gemini` to enter the interactive CLI, then run the `/about` command.

```console
> /about
Reproduced from source on current main. Platform: macOS. CLI Version: 0.59.0-nightly.20260825.g812f7a2bc
```

### Login information

Not auth-related. Logic bug in sanitizeToolArgs().

### Anything else we need to know?

Suggested direction (small, localized):

Build a Set of normalized patterns (password, apikey, token, auth, …).
Treat a key as sensitive only if keyNormalized === pattern (or the key equals/ends with _+pattern after restoring separators), not .includes(pattern).
Add tests:
max_tokens: 8192 is kept
author: 'alice' is kept
password / api_key / access_token still redact
I'd like to send a focused PR with tests after this is labeled help wanted.

Contributor guide

Open the contributing guide

Research direction

Start in packages/core/src/utils/agent-sanitization-utils.ts and inspect the existing tests in agent-sanitization-utils.test.ts. Reproduce the false positives for max_tokens and author, then verify that password, api_key, and access_token remain redacted while non-secret keys retain their values.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.