feat: enhance security and performance by adding internal secret handling and replay protection#179
Merged
Conversation
| const logsDir = getLogsDir(); | ||
| mkdirSync(logsDir, { recursive: true }); | ||
| // 0o700: only owner can traverse/read the logs directory | ||
| mkdirSync(logsDir, { recursive: true, mode: 0o700 }); |
| this.logPath = join(logsDir, `${sessionId}.log`); | ||
| this.stream = createWriteStream(this.logPath, { flags: "a" }); | ||
| // 0o600: only owner can read the log file (contains PTY transcripts with potential secrets) | ||
| this.stream = createWriteStream(this.logPath, { flags: "a", mode: 0o600 }); |
| const gzip = createGzip(); | ||
| const dest = createWriteStream(gzPath); | ||
| // 0o600: same owner-only restriction on the compressed archive | ||
| const dest = createWriteStream(gzPath, { mode: 0o600 }); |
| const hubDir = getHubDir(); | ||
| mkdirSync(hubDir, { recursive: true }); | ||
| // 0o700: only owner can traverse; mode is set on creation and enforced after | ||
| mkdirSync(hubDir, { recursive: true, mode: 0o700 }); |
| mkdirSync(hubDir, { recursive: true }); | ||
| // 0o700: only owner can traverse; mode is set on creation and enforced after | ||
| mkdirSync(hubDir, { recursive: true, mode: 0o700 }); | ||
| chmodSync(hubDir, 0o700); |
| startedAt, | ||
| }; | ||
| writeFileSync(getHubConfigPath(), JSON.stringify(hubConfig, null, 2) + "\n", "utf-8"); | ||
| writeFileSync(getHubConfigPath(), JSON.stringify(hubConfig, null, 2) + "\n", { encoding: "utf-8", mode: 0o600 }); |
| }; | ||
| writeFileSync(getHubConfigPath(), JSON.stringify(hubConfig, null, 2) + "\n", "utf-8"); | ||
| writeFileSync(getHubConfigPath(), JSON.stringify(hubConfig, null, 2) + "\n", { encoding: "utf-8", mode: 0o600 }); | ||
| chmodSync(getHubConfigPath(), 0o600); |
| const dir = dirname(path); | ||
| mkdirSync(dir, { recursive: true }); | ||
| // 0o700: only owner can traverse; mode enforced after creation for existing dirs | ||
| mkdirSync(dir, { recursive: true, mode: 0o700 }); |
|
|
||
| writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf-8"); | ||
| // 0o600: only owner can read; mode + explicit chmod covers both new and existing files | ||
| writeFileSync(path, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 0o600 }); |
| writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf-8"); | ||
| // 0o600: only owner can read; mode + explicit chmod covers both new and existing files | ||
| writeFileSync(path, JSON.stringify(data, null, 2) + "\n", { encoding: "utf-8", mode: 0o600 }); | ||
| chmodSync(path, 0o600); |
…ling and replay protection
The internal API now requires an X-Hub-Internal-Secret header on all endpoints except /api/health. Both test files were missing this: - createInternalApi calls now include internalSecret - httpRequest helpers now send the x-hub-internal-secret header - Updated error-message assertion to match the improved error text Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.