Skip to content

fix(traffic): keep store directories out of host deletion - #556

Merged
BaaRai merged 4 commits into
BaaRai:mainfrom
Coff0xc:fix/traffic-host-reserved
Nov 26, 2026
Merged

BaaRai merged 4 commits into
BaaRai:mainfrom
Coff0xc:fix/traffic-host-reserved

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Deleting an exact host list built a directory from every requested name. _index, _blobs, _ca, and _delete_staging are the capture index, the blob store, the MITM CA, and the delete staging area, so those names were moved out with the host trees. . and .. named the traffic directory or its parent.

Index rows for such a host are still removed. Those directories are not.

go test -count=1 -run "TestHostDirSkipsStorePaths|TestDeleteHostsExactSkipsStoreDirs|TestDeleteHostsExact$" ./traffic/ passed.

DeleteHostsExact built a directory path from every requested host. A name that sanitizes to _index, _blobs, _ca, or _delete_staging is the store itself, so the batch delete moved those directories out with the host trees. Index rows for the host are still removed.
@5P34R

5P34R commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Review notes

Correct on Linux, and the test fails without the fix. It can still be bypassed on case-insensitive filesystems, though.

Required:

  • Reject every sanitized name that starts with _. hostDir compares exact names (_index, _blobs, _ca, _delete_staging), and deleteTrafficHosts (server/server.go:3707-3712) doesn't lowercase the hosts it receives. On macOS/Windows, {"hosts":["_CA"]} stages the MITM CA directory for deletion, and on Windows so does _ca. (trailing dot). allHostTrees (traffic/traffic.go:1627) already uses the "starts with _" rule, and the PR's own comment mentions it.

Nit: the filepath.Rel check in hostDir can never trigger, because sanitize already strips separators. It's harmless.

@BaaRai
BaaRai force-pushed the fix/traffic-host-reserved branch from 483d174 to ed6d0cb Compare November 26, 2026 22:09
@BaaRai
BaaRai force-pushed the fix/traffic-host-reserved branch from ed6d0cb to e47776f Compare November 26, 2026 22:24
BaaRai added a commit to 5P34R/ARTEX that referenced this pull request Nov 26, 2026
@BaaRai
BaaRai merged commit 51d17fe into BaaRai:main Nov 26, 2026
6 checks passed
@BaaRai

BaaRai commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Merged, thanks @Coff0xc. Rebased on current main and verified with its tests and negative control.

BaaRai added a commit that referenced this pull request Nov 26, 2026
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.

3 participants