Skip to content

feat: enhance security and performance by adding internal secret handling and replay protection#179

Merged
shrijayan merged 2 commits into
mainfrom
security-fix
Jun 24, 2026
Merged

feat: enhance security and performance by adding internal secret handling and replay protection#179
shrijayan merged 2 commits into
mainfrom
security-fix

Conversation

@shrijayan

Copy link
Copy Markdown
Owner

No description provided.

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);
shrijayan and others added 2 commits June 24, 2026 18:11
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>
@shrijayan shrijayan merged commit c68b11b into main Jun 24, 2026
6 checks passed
@shrijayan shrijayan deleted the security-fix branch June 24, 2026 12:44
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.

2 participants