Skip to content

fix: add system UID range validation to prevent privilege escalation#267

Merged
Mossaka merged 4 commits intomainfrom
copilot/add-uid-gid-range-check
Jan 17, 2026
Merged

fix: add system UID range validation to prevent privilege escalation#267
Mossaka merged 4 commits intomainfrom
copilot/add-uid-gid-range-check

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

UID/GID validation in getSafeHostUid() and getSafeHostGid() didn't reject system UIDs (0-999), potentially allowing container user mappings with unintended privileges.

Changes

  • Add MIN_REGULAR_UID constant (1000) as the threshold for regular users
  • Add validateIdNotInSystemRange() that falls back to 1000 for any system UID/GID
  • Update both getSafeHostUid() and getSafeHostGid() to validate all sources (process.getuid/getgid() and SUDO_UID/SUDO_GID)
  • Add 15 unit tests covering system/regular UID scenarios

Example

// Before: system UID 13 (proxy user) would be used as-is
process.getuid = () => 13;
getSafeHostUid(); // returned "13"

// After: system UIDs fall back to 1000
process.getuid = () => 13;
getSafeHostUid(); // returns "1000"
Original prompt

This section details on the original issue you should resolve

<issue_title>[Security] UID/GID validation lacks system UID range checking</issue_title>
<issue_description>## Priority
Low

Description

The current UID/GID validation doesn't check against system UID ranges. This could allow using system UIDs (typically 0-999) which may have unintended privileges.

Impact

  • Severity: Low
  • Attack Vector: Using system UIDs could bypass some security checks
  • Risk: Privilege escalation via system UID usage

Proposed Solution

Add validation to reject system UID ranges:

// Reject UIDs 0-999 (system range on most Linux distributions)
if (uid < 1000) {
  throw new Error('UID must be >= 1000 (system UIDs not allowed)');
}

Effort Estimate

~1 hour

References

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add UID/GID validation for system UID ranges fix: add system UID range validation to prevent privilege escalation Jan 17, 2026
Copilot AI requested a review from Mossaka January 17, 2026 04:52
@Mossaka Mossaka marked this pull request as ready for review January 17, 2026 09:13
@github-actions
Copy link

github-actions bot commented Jan 17, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 77.19% 77.81% 📈 +0.62%
Statements 77.27% 77.88% 📈 +0.61%
Functions 77.17% 77.29% 📈 +0.12%
Branches 69.76% 70.96% 📈 +1.20%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 75.9% → 79.1% (+3.27%) 75.2% → 78.4% (+3.18%)

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

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

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

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

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

@github-actions
Copy link

Smoke Test Results

Last 2 merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PRs successfully
  • ✅ Playwright: Page title contains "GitHub"
  • ✅ File Write: Created test file
  • ✅ Bash: Verified file contents

Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Successfully retrieved PR data
  • ✅ Playwright: Page title verified (contains "GitHub")
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-21092098430.txt
  • ✅ Bash Tool: File verified with content "Smoke test passed for Copilot at Sat Jan 17 09:26:32 UTC 2026"

Overall Status: PASS 🎉

cc: @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

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

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link

github-actions bot commented Jan 17, 2026

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

@github-actions
Copy link

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP - Retrieved PRs successfully
  • ✅ Playwright - Navigated to GitHub, page title verified
  • ✅ File Writing - Created test file
  • ✅ Bash Tool - Verified file contents

Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data successfully
  • ❌ Playwright: Browser installation timeout
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-copilot-21092323162.txt
  • ✅ Bash Tool: Verified file content

Status: FAIL (Playwright test failed)

cc: @Mossaka

AI generated by Smoke Copilot

@Mossaka Mossaka merged commit ac4129c into main Jan 17, 2026
47 of 49 checks passed
@Mossaka Mossaka deleted the copilot/add-uid-gid-range-check branch January 17, 2026 20:33
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.

[Security] UID/GID validation lacks system UID range checking

2 participants