Skip to content

fix: use secure temp directory in volume-mounts test#765

Merged
Mossaka merged 1 commit intomainfrom
fix/insecure-temp-file
Feb 12, 2026
Merged

fix: use secure temp directory in volume-mounts test#765
Mossaka merged 1 commit intomainfrom
fix/insecure-temp-file

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 12, 2026

Summary

  • Replace predictable /tmp/secret-file-12345.txt path with fs.mkdtempSync to create a unique temporary directory, preventing symlink attacks (CodeQL alert smoke test: copilot engine validation (run 20643921403) #173)
  • Write secret file with restrictive permissions (0o600) inside the secure temp directory
  • Update cleanup to recursively remove the temp directory instead of unlinking a single file

Test plan

  • npm run build compiles successfully
  • Integration tests pass (Test 4 still verifies container can't access host files outside custom mounts)

🤖 Generated with Claude Code

Replace predictable /tmp/secret-file-12345.txt path with
fs.mkdtempSync to prevent symlink attacks (CodeQL alert #173).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 12, 2026 20:13
@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 12, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.26% 82.42% 📈 +0.16%
Statements 82.31% 82.47% 📈 +0.16%
Functions 82.14% 82.14% ➡️ +0.00%
Branches 74.70% 74.80% 📈 +0.10%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.5% → 84.2% (+0.67%) 83.0% → 83.6% (+0.65%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses CodeQL security alert #173 by replacing a predictable temporary file path with a secure temporary directory in the volume-mounts integration test. The change prevents potential symlink attacks by using fs.mkdtempSync to create a unique directory with restrictive permissions.

Changes:

  • Replaced hardcoded /tmp/secret-file-12345.txt path with fs.mkdtempSync for secure temp directory creation
  • Set restrictive file permissions (0o600) when writing the secret file
  • Updated cleanup logic to recursively remove the temporary directory instead of unlinking a single file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try {
const result = await runner.runWithSudo(
'sh -c "cat /data/test.txt && cat /tmp/secret-file-12345.txt"',
`sh -c "cat /data/test.txt && cat ${secretFile}"`,
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The secretFile path is directly interpolated into the shell command without proper escaping. If the path contains spaces or special characters (which is possible if os.tmpdir() returns such a path), the command will fail or could potentially be exploited. Consider using proper shell escaping or wrapping the path in quotes.

See below for a potential fix:

      const escapedSecretFile = secretFile.replace(/'/g, `'\\''`);
      const result = await runner.runWithSudo(
        `sh -c "cat /data/test.txt && cat '${escapedSecretFile}'"`,

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot mentioned this pull request Feb 12, 2026
@github-actions
Copy link
Contributor

Deno Build Test Results

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests completed successfully.

AI generated by Build Test Deno

@github-actions
Copy link
Contributor

Bun Build Test Results

Project Install Tests Status
elysia 1/1 PASS
hono 1/1 PASS

Overall: PASS

All Bun projects built and tested successfully.

AI generated by Build Test Bun

@github-actions
Copy link
Contributor

Build Test: C++ - PASS ✅

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 merged PRs:

✅ GitHub MCP: PASS
✅ Playwright: PASS (page title contains "GitHub")
✅ File Writing: PASS
✅ Bash Tool: PASS

Overall Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

Node.js Build Test Results

Project Install Tests Status
clsx PASS PASS
execa PASS PASS
p-limit PASS PASS

Overall: PASS

All Node.js projects installed successfully and passed their tests.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

Go Build Test Results

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

All Go projects built and tested successfully.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

Smoke Test Results (Run 21962630565)

Last 2 merged PRs:

✅ GitHub MCP - Last 2 PRs retrieved
✅ Playwright - Page title: "GitHub · Change is constant. GitHub keeps you ahead. · GitHub"
✅ File Writing - Created /tmp/gh-aw/agent/smoke-test-copilot-21962630565.txt
✅ Bash Tool - Verified file content

Status: PASS

cc: @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Smoke test results:
GitHub MCP merged PRs: fix: review recommendations for PR #720; fix: eliminate nested bash layer in chroot command execution for Java/.NET ✅
Safeinputs gh PR list: fix: replace unanchored regex with string assertions in tests; fix: eliminate TOCTOU race conditions in ssl-bump.ts ✅
Playwright GitHub title contains "GitHub" ✅
Tavily search "GitHub Agentic Workflows Firewall" ❌ (tool missing)
File write smoke-test-codex-21962630540.txt ✅
Bash cat verify ✅
Discussion query + comment ✅
Build npm ci && npm run build ✅
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

Rust Build Test Results

Project Build Tests Status
fd 1/1 PASS
zoxide 1/1 PASS

Overall: PASS

All Rust projects built successfully and all tests passed.

AI generated by Build Test Rust

@github-actions
Copy link
Contributor

.NET Build Test Results

Project Restore Build Run Status
hello-world PASS
json-parse PASS

Overall: PASS

All .NET projects successfully restored, built, and ran with expected output.

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

Build Test: Java ✅

All Java projects successfully built and tested through AWF firewall.

Project Compile Tests Status
gson 1/1 PASS
caffeine 1/1 PASS

Overall: PASS

Maven successfully downloaded dependencies through Squid proxy (172.30.0.10:3128) using configured ~/.m2/settings.xml.

AI generated by Build Test Java

@Mossaka Mossaka merged commit e94be9b into main Feb 12, 2026
91 checks passed
@Mossaka Mossaka deleted the fix/insecure-temp-file branch February 12, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant