Skip to content

fix: add NAT blacklist for dangerous ports in iptables#269

Merged
Mossaka merged 4 commits intomainfrom
copilot/add-nat-blacklist-for-ports
Jan 17, 2026
Merged

fix: add NAT blacklist for dangerous ports in iptables#269
Mossaka merged 4 commits intomainfrom
copilot/add-nat-blacklist-for-ports

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Adds defense-in-depth layer at the iptables NAT level to block dangerous ports, complementing existing Squid ACL filtering.

Changes

  • Added DANGEROUS_PORTS array in containers/agent/setup-iptables.sh matching the list in squid-config.ts
  • Inserted NAT RETURN rules for dangerous ports before DNAT redirect rules
  • Traffic to blocked ports bypasses NAT and hits the OUTPUT chain's final DROP rule

Blocked Ports

SSH (22), Telnet (23), SMTP (25), POP3 (110), IMAP (143), SMB (445), MSSQL (1433), Oracle (1521), MySQL (3306), RDP (3389), PostgreSQL (5432), Redis (6379), MongoDB (27017/27018/28017)

Traffic Flow

Dangerous port traffic → NAT RETURN → OUTPUT DROP (blocked)
Allowed port traffic   → NAT DNAT   → Squid proxy → domain ACL
Original prompt

This section details on the original issue you should resolve

<issue_title>[Security] Port filtering should use explicit NAT blacklist</issue_title>
<issue_description>## Priority
Low

Description

Current port filtering implementation could be strengthened by using an explicit NAT blacklist for dangerous ports rather than relying solely on ACL filtering.

Impact

  • Severity: Low
  • Attack Vector: Bypass of ACL filtering in edge cases
  • Risk: Access to dangerous ports if ACL fails

Proposed Solution

Implement explicit iptables NAT rules to blacklist dangerous ports:

# Block dangerous ports in NAT PREROUTING
iptables -t nat -A PREROUTING -p tcp --dport 22 -j RETURN
iptables -t nat -A PREROUTING -p tcp --dport 3306 -j RETURN
# ... etc

This provides defense-in-depth beyond Squid ACL filtering.

Effort Estimate

~2 hours

References

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add explicit NAT blacklist for port filtering fix: add NAT blacklist for dangerous ports in iptables Jan 17, 2026
Copilot AI requested a review from Mossaka January 17, 2026 04:31
@Mossaka Mossaka marked this pull request as ready for review January 17, 2026 09:14
@github-actions
Copy link

github-actions bot commented Jan 17, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 77.19% 77.19% ➡️ +0.00%
Statements 77.27% 77.27% ➡️ +0.00%
Functions 77.17% 77.17% ➡️ +0.00%
Branches 69.76% 69.76% ➡️ +0.00%

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

@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 (Claude)

Last 2 Merged PRs:

Test Results:

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

Overall Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link

✅ Smoke Test PASSED

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data
  • ✅ Playwright: Verified github.com title contains "GitHub"
  • ✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-copilot-21092098373.txt
  • ✅ Bash Tool: Verified file content

cc: @Mossaka @copilot

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 - Claude Engine

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved PR data successfully
  • ✅ Playwright: Navigated to github.com, title contains "GitHub"
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-claude-21092322278.txt
  • ✅ 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: Retrieved PRs successfully
  • ❌ Playwright: Missing system libraries (libglib-2.0.so.0) - curl test passed ✅
  • ✅ File Write: Created /tmp/gh-aw/agent/smoke-test-copilot-21092322273.txt
  • ✅ Bash Tool: File verified successfully

Overall: PARTIAL PASS (4/5 - Playwright library issue)

cc: @Mossaka

AI generated by Smoke Copilot

@Mossaka Mossaka merged commit db682c1 into main Jan 17, 2026
44 of 45 checks passed
@Mossaka Mossaka deleted the copilot/add-nat-blacklist-for-ports branch January 17, 2026 20:20
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] Port filtering should use explicit NAT blacklist

2 participants