Skip to content

Commit c3650e4

Browse files
committed
chore: enable SecretString and overflow checks for security
API keys now stored as `secrecy::SecretString` with memory zeroed on drop and `[REDACTED]` in debug output. Release profile updated to `lto = "fat"`, `strip = "symbols"`, and `overflow-checks = true` for ANSSI-FR compliance.
1 parent 0852a55 commit c3650e4

5 files changed

Lines changed: 16 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ All notable changes to CommitBee are documented here.
3939

4040
- **API key validation ordering**`set-key`, `get-key`, `init`, `config`, `completions`, and `hook` commands no longer require an API key to be present. CLI `--provider` flag now applies before keyring lookup.
4141
- **Platform-native keyring backends** — keyring v3 now uses macOS Keychain (`apple-native`), Windows Credential Manager (`windows-native`), and Linux Secret Service (`linux-native`) instead of a mock file-based backend.
42+
- **SecretString for API keys** — API keys stored as `secrecy::SecretString` in Config and provider structs. Memory zeroed on drop, never exposed except at HTTP header insertion.
43+
- **Overflow checks in release builds**`overflow-checks = true` added to release profile for ANSSI-FR compliance.
4244

4345
### Testing
4446

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ When adding or modifying LLM providers (`src/services/llm/`), every provider mus
198198
5. **Zero-allocation streaming** — parse from `&line_buffer[..newline_pos]` slices, then `drain(..=newline_pos)` instead of allocating new Strings per line
199199
6. **Shared system prompt** — use `super::SYSTEM_PROMPT`, never duplicate prompt text
200200
7. **CancellationToken** — check in `tokio::select!` loop alongside stream chunks
201+
8. **SecretString for API keys** — store as `secrecy::SecretString`, expose only via `.expose_secret()` at HTTP header insertion. Never log, Debug, or Display the raw key.
201202

202203
### Commit Type Conventions
203204

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ all-languages = [
128128
]
129129

130130
[profile.release]
131-
lto = true
132-
strip = true
131+
lto = "fat"
132+
strip = "symbols"
133133
codegen-units = 1
134134
overflow-checks = true
135135

DOCS.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,20 @@ export ANTHROPIC_API_KEY=sk-ant-...
356356

357357
### Secure Key Storage
358358

359-
If built with the `secure-storage` feature, CommitBee can store API keys in your OS keychain using platform-native backends (macOS Keychain, Windows Credential Manager, Linux Secret Service):
359+
API keys are stored as `secrecy::SecretString` — memory is zeroed on drop and keys show as `[REDACTED]` in debug output. Keys are only exposed at the HTTP header insertion point.
360+
361+
The `secure-storage` feature (enabled by default) stores keys in your OS keychain using platform-native backends (macOS Keychain, Windows Credential Manager, Linux Secret Service):
360362

361363
```bash
362-
cargo install commitbee --features secure-storage
363364
commitbee config set-key openai # Prompts for key, stores in keychain
364365
commitbee config set-key anthropic # Same for Anthropic
365366
commitbee config get-key openai # Check if key exists
366367
```
367368

368369
Key lookup order: CLI `--provider` flag → config file → environment variable → keychain. The `set-key` and `get-key` commands do not require an API key to already be configured.
369370

371+
To build without keychain support: `cargo install commitbee --no-default-features --features all-languages`
372+
370373
## ✂️ Commit Splitting
371374

372375
One of CommitBee's standout features. When your staged changes contain logically independent work, CommitBee detects this and offers to create separate commits.

PRD.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
66

77
# CommitBee — Product Requirements Document
88

9-
**Version**: 5.1
9+
**Version**: 5.2
1010
**Date**: 2026-03-28
1111
**Status**: Active
1212
**Author**: [Sephyi](https://github.com/Sephyi) + [Claude Opus 4.6](https://www.anthropic.com/news/claude-opus-4-6)
1313

1414
## Changelog
1515

1616
<details>
17-
<summary>Revision history (v3.3 → v5.1)</summary>
17+
<summary>Revision history (v3.3 → v5.2)</summary>
1818

1919
| Version | Date | Summary |
2020
| ------- | ---------- | ------- |
21+
| 5.2 | 2026-03-28 | Security hardening: `secrecy::SecretString` for API keys (F-004), overflow-checks in release profile (F-001). Updated SR-002, DR-005, DR-006. |
2122
| 5.1 | 2026-03-28 | fix: keyring platform-native backends, API key validation ordering for set-key command. Updated FR-019 and SR-002. |
2223
| 5.0 | 2026-03-28 | PRD structural overhaul: removed stale §3.1 Resolved Issues (all v0.2.0), removed Dependency Status table, removed dead ORCommit references. Updated §2 competitive landscape for 2026 (added IDE-native competitors: GitHub Copilot Desktop, Cursor, Windsurf; updated star counts; refreshed feature matrix). Updated §3 codebase structure (added diff.rs, differ.rs, progress.rs). Updated PE-001/PE-002 with v0.6.0 prompt sections (STRUCTURED CHANGES, IMPORTS, RELATED FILES, INTENT). Updated PR-005 with adaptive budget. Added v0.6.0 feature section §4.6 (FR-064–FR-072). Renumbered Future to §4.7. |
2324
| 4.4 | 2026-03-27 | Added future requirements from audit: FR-073 (move detection), FR-074 (AST-based splitting), FR-075 (configurable categorization), TR-008 (LLM quality testing), PE-007 (token-accurate budgets). |
@@ -548,6 +549,7 @@ Allow users to define custom file category patterns in config (e.g., `[categoriz
548549

549550
### SR-002: API Key Management
550551

552+
- **In-memory protection**: API keys stored as `secrecy::SecretString` in Config and provider structs — memory zeroed on drop, `[REDACTED]` in Debug output, only exposed at HTTP header insertion via `.expose_secret()`
551553
- System keychain via `keyring` with platform-native backends: `apple-native` (macOS Keychain), `linux-native` (Linux Secret Service), `windows-native` (Windows Credential Manager)
552554
- Environment variable fallback
553555
- Never stores keys in plaintext config
@@ -795,8 +797,9 @@ bash, zsh, fish, powershell via `clap_complete`. Documented installation per she
795797
[profile.release]
796798
lto = true
797799
strip = true
798-
codegen-units = 1
799800
opt-level = "z" # or "s" — benchmark both
801+
codegen-units = 1
802+
overflow-checks = true # ANSSI-FR compliance
800803
```
801804

802805
### DR-006: Feature Flags

0 commit comments

Comments
 (0)