Skip to content

fix: CTF Makefile audit — resolve 3 critical, 4 high, 8 medium findings#154

Open
t0kubetsu wants to merge 1 commit into
mainfrom
fix/ctf-makefiles-audit
Open

fix: CTF Makefile audit — resolve 3 critical, 4 high, 8 medium findings#154
t0kubetsu wants to merge 1 commit into
mainfrom
fix/ctf-makefiles-audit

Conversation

@t0kubetsu
Copy link
Copy Markdown

@t0kubetsu t0kubetsu commented May 11, 2026

Summary

Resolves all findings from the audit of the 18 CTF lab Makefiles. The clean target was host-destructive, three labs had wrong SERVICE variables silently targeting sibling exercises, and every file was missing .PHONY declarations. All fixes are applied template-first and propagated uniformly.

Closes #153

Changes

Critical fixes

  • C1 — Replace host-wide clean block (docker system prune + docker ps -aq / docker images -q / docker volume ls -q) with scoped docker compose down --rmi all --volumes --remove-orphans (all 18 files)
  • C2 — Fix wrong SERVICE in CVE-2024-6387/Makefile: openssh-cve-2018-15473openssh-cve-2024-6387
  • C3 — Fix wrong SERVICE in CVE-2019-11043/Makefile: apache-cve-2021-42013php-cve-2019-11043

High fixes

  • H1 — Eliminate $(shell docker ps -aq) / $(shell docker images -q) parse-time expansion (removed with C1)
  • H2 — Fix stop-debug-build hardcoded debug literal → $(DEBUG_SERVICE) (all 18 files)
  • H3 — Scope docker compose build and docker compose up -d to $(SERVICE) in all build/rebuild targets (all 18 files)
  • H4 — Resolved as part of C1 fix

Medium fixes

  • M1 — Add .PHONY declarations for all targets (all 18 files)
  • M2 — Add print: help alias (advertised in help text but missing)
  • M3 — Update CVE-2023-34092 SERVICE and compose.yml service name: vite-cve-2022-44615vite-cve-2023-34092
  • M4 — Remove dead 5-line commented block from term-debug-build (all 18 files)
  • M5 — Fix stop-debug-build comment: # stop only debug# stop and remove debug
  • M6 — Set blank_template/Makefile SERVICE = REPLACE_ME (was tomcat-cve-2025-24813 — root cause of C2/C3)
  • M7 — Fix lpe-01 duplicate make term help entry; expose make term-user properly with description
  • M8 — Resolved as part of C1 fix

Low fixes

  • L1 — Normalize ISSUE header formats to # ISSUE N across all files
  • L2 — Standardize term shell to /bin/bash (vite CVEs used /bin/sh)
  • L3 — Remove trailing whitespace on target definition lines

Files Changed

File Change
cve/blank_template/Makefile Template: all fixes + SERVICE = REPLACE_ME
cve/network/openssh/CVE-2024-6387/Makefile C2: correct SERVICE + all template fixes
cve/web/php/CVE-2019-11043/Makefile C3: correct SERVICE + all template fixes
cve/web/vite/CVE-2023-34092/Makefile M3: correct SERVICE + all template fixes
cve/web/vite/CVE-2023-34092/compose.yml M3: rename service key + container_name
misconfiguration/system/lpe-01/Makefile M7: fix help duplication; expose term-user
13 remaining Makefiles All template fixes (C1, H2, H3, M1–M6, L1–L3)

Testing

Each Makefile was validated by grep assertions:

  • .PHONY present in all 18 ✓
  • docker system prune absent in all 18 ✓
  • docker compose build (unscoped) absent in all 18 ✓
  • rm -sf debug literal absent in all 18 ✓
  • print: help present in all 18 ✓
  • Dead comment block absent in all 18 ✓
  • SERVICE spot-checked on C2/C3/M3/M6 targets ✓

…gs (#153)

Critical fixes:
- C1: Replace host-wide `docker system prune` + `docker ps -aq` clean target
  with scoped `docker compose down --rmi all --volumes --remove-orphans`
- C2: Fix wrong SERVICE in CVE-2024-6387 (was openssh-cve-2018-15473)
- C3: Fix wrong SERVICE in CVE-2019-11043 (was apache-cve-2021-42013)

High fixes:
- H1: Eliminate $(shell docker ps -aq) parse-time expansion in all files
- H2: Fix stop-debug-build hardcoded 'debug' literal → $(DEBUG_SERVICE)
- H3: Scope docker compose build/up to $(SERVICE) in all build targets
- H4: Moot — resolved by C1 fix

Medium fixes:
- M1: Add .PHONY declarations to all 18 Makefiles
- M2: Add `print: help` alias (was advertised but missing)
- M3: Update vite CVE-2023-34092 SERVICE + compose.yml service name
  (stale vite-cve-2022-44615 from pre-rename)
- M4: Remove dead 5-line commented block from term-debug-build
- M5: Fix stop-debug-build comment ("stop only" → "stop and remove")
- M6: Set blank_template SERVICE = REPLACE_ME (was tomcat service name)
- M7: Fix lpe-01 duplicate help entry; expose make term-user properly
- M8: Moot — resolved by C1 fix

Low fixes:
- L1: Normalize ISSUE header formats to `# ISSUE N` across all files
- L2: Standardize term shell to /bin/bash (vite CVEs used /bin/sh)
- L3: Remove trailing whitespace on target definition lines
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.

fix: CTF Makefile audit — 3 critical · 4 high · 8 medium findings across 18 lab Makefiles

1 participant