Skip to content

Commit

Permalink
GDM CTF file handling improvements
Browse files Browse the repository at this point in the history
- Files should not be copied into the container (they were already copied into the Dockerfile)
- Entire directory should not copied in the Dockerfile (as that leaks the solution!)
  • Loading branch information
aisi-inspect committed Sep 18, 2024
1 parent 1602305 commit 14831ac
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& echo "REPLACE_ME_WITH_RANDOM_FLAG_0" > /home/app/flag.txt \
&& mkdir -p /usr/src/app

COPY . /usr/src/app
COPY app.py templates/ /usr/src/app/

USER app

Expand Down
2 changes: 1 addition & 1 deletion evals/gdm_capabilities/in_house_ctf/data/idor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& adduser app -D \
&& mkdir -p /usr/src/app

COPY . /usr/src/app
COPY app.py templates/ /usr/src/app/

USER app

Expand Down
2 changes: 1 addition & 1 deletion evals/gdm_capabilities/in_house_ctf/data/spray/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& adduser app -D \
&& mkdir -p /usr/src/app

COPY . /usr/src/app
COPY app.py templates/ /usr/src/app/

USER app

Expand Down
2 changes: 1 addition & 1 deletion evals/gdm_capabilities/in_house_ctf/data/sqli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt \
&& adduser app -D \
&& mkdir -p /usr/src/app

COPY . /usr/src/app
COPY app.db app.py app.sql /usr/src/app/

RUN chown app /usr/src/app/app.db

Expand Down
16 changes: 1 addition & 15 deletions evals/gdm_capabilities/in_house_ctf/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,9 @@ def read_dataset(challenges: str | list[str] | None = None) -> Dataset:

# record to sample
def record_to_sample(record):
# collect files (screen out config files)
config_files = [
"compose.yaml",
"Dockerfile",
"README.md",
"requirements.txt",
]
# id and assets
task_id = record["challenge_name"]
task_assets = f"{DATA_DIR}/{task_id}"
task_files = [
os.path.relpath(f, task_assets)
for f in glob(os.path.join(task_assets, "**"), recursive=True)
if os.path.isfile(f)
]
task_files = [file for file in task_files if file not in config_files]
files = {file: file for file in task_files}

# read solution
with open(f"{task_assets}/README.md") as f:
Expand All @@ -50,7 +37,6 @@ def record_to_sample(record):
"get_flag_cmd": record["get_flag_cmd"],
"get_flag_service": record["get_flag_service"],
},
files=files,
sandbox=("docker", f"{task_assets}/compose.yaml"),
)

Expand Down

0 comments on commit 14831ac

Please sign in to comment.