#31349 ci: detect outbound internet traffic generated while running tests
| Reviewability | Reviews | Agreement | Size | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| #31349 ci: detect outbound internet traffic generated while running tests | Author silent 136d | 1 (+2) | Mild | 0 + 77 tests | ||||||
|
|
|
|
| ||||||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | ||||||||||
Goal
Runs `tcpdump` during CI test execution to detect unexpected outbound TCP, UDP, or DNS network traffic. If any test stage (unit, functional, tidy, IWYU, fuzz) emits outbound packets on non-loopback interfaces or local DNS queries on port 53, the CI step dumps the captured packets and fails.
Problem: Tests running in CI can inadvertently generate outbound network traffic or DNS queries to the internet (for instance, via node initialization, DNS seeds, or RPC network calls), violating test hermeticity and potentially leaking test environment data or causing flakiness.
Evidence of importance:
- Resolves issue #31339 regarding unwanted outbound network traffic during test runs.
- Author notes that CI VMs can route DNS lookups externally: 'DNS traffic is detected because some VMs have configured a non-loopback DNS server, [1111:1111::1]:53. This is achieved by running tcpdump during tests and inspecting its output after the tests.'
Scope: The PR description mentions fixing `node_init_tests/init_test`, but the commit and diff modify only CI scripts and Docker options (`ci/test/*`), adding `tcpdump` and `net-tools` without touching test code.
Reviewability
Stale · Author silent 136d
No author activity for 136 days; a review may wait a long time for a response.
Waiting on (from the thread read):
- author: address tcpdump --direction no-op flag in traffic monitor reading logic 2026-08-28
Agreement
Mild
objection that needs an answer is contested (fjahr)
Thread notes: Added ryanofsky's code review ACK (r:5268027561) and inline response (rc:4063256570) confirming fjahr's point that --direction is a no-op when reading capture files; the nonblocking claim remains open awaiting an author update.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| laanwj (member) | objection, approach | False-positive CI failures if unrelated background daemons on the CI host VM generate network traffic | answered · laanwj did not follow up after author rationale · v1, not yet re-checked | answered | yes | 2024-11-25: 'i'm slightly worried this may generate false positive. As is, this detects traffic on the entire (virtual) machine while running the tests. Are there no other daemons running on the CI instance that c' Status from: 2024-11-27: vasild: 'About the false positives - I think it is worth trying this in its current mode where any detected traffic is assumed to' |
| maflcko (member) | objection, correctness | tcpdump buffers output when writing to a file, causing captured packets to be missed when the file is read | fixed · fix pushed · Fixed by adding -U flag · v1, not yet re-checked | answered | yes | 2024-12-03: 'I don't think this works reliably? See: ... Use the -U flag to cause packets to be written as soon as they are received.' Status from: 2024-12-04: vasild: 'Even better! Added `-U`.' |
| maflcko (member) | objection, correctness | Silently ignoring return codes and omitting pipefail allows broken network detection to pass CI silently | fixed · fix pushed · Pipefail enabled in CI scripts · v1, not yet re-checked | changed | yes | 2024-12-04: 'Ignoring the return code in all tasks can mean that even the tasks where the detection is working are going to silently break tomorrow. As mentioned previously in the thread you closed, I think this i' Status from: 2024-12-05: vasild: 'Enabled `pipefail` as in the above diff. Thanks!' |
| fanquake (member) | objection, approach | CI scripts fail when run locally under Podman due to external DNS traffic, breaking supported local test workflows | fixed · fix pushed · Mitigated with -dnsseed=0 and test fix in #35193 · v1, not yet re-checked | changed | yes | 2025-10-16: 'Yea, I have seen the same, on one of my Fedora boxes, which would be a blocker, given it breaks running the CI locally.' Status from: 2026-05-15: vasild: 'with the addition of `-dnsseed=0` this should be robust and work as intended on docker or podman, locally or in CI cloud' |
| maflcko (member) | objection, correctness | Non-deterministic false-positive test failures during local CI runs under Podman | fixed · fix pushed · maflcko re-Concept ACKed after fixes · v1, not yet re-checked | changed | yes | 2026-02-04: 'The current failures are non-deterministic, which is a blocker to merging this. We have enough intermittent issues already, and I don't think it is a good use of time to add more, when there isn't eve' Status from: 2026-05-15: vasild: 'with the addition of `-dnsseed=0` this should be robust and work as intended on docker or podman, locally or in CI cloud' |
| ryanofsky (member) | objection, correctness | filter variable is not reset for non-loopback interfaces and persists across invocations, which could ignore non-port-53 traffic | fixed · fix pushed · Fixed variable resetting and scoping · v1, not yet re-checked | answered | yes | 2026-05-18: 'Looks like there is a bug here because `filter` variable is not reset if `ifname` does not begin with "lo". Also filter is not declared as a local variable so it will persist between calls.' Status from: 2026-06-18: vasild: 'Done, thanks!' |
| fjahr (member) | objection, correctness | tcpdump --direction is only enforced during packet capture and acts as a no-op when reading files, failing to filter direction | contested · ryanofsky agreed the flag is a no-op and suggested dropping or moving it; not yet addressed in code · v1, not yet re-checked | answered | by others | 2026-08-28: 'It seems that `--direction` is only enforced at capture time, so it should be moved to the tcpdump call in `traffic_monitor_begin()`. Or maybe just delete here if we don't want to filter there because' |
Support:
- maflcko (member) (Concept ACK, 2024-11-22): Nice. Conecpt ACK! [not substantive]
- laanwj (member) (Concept ACK, 2024-11-25): Concept ACK [not substantive]
- 1440000bytes (contributor) (Concept ACK, 2024-11-26): Concept ACK [not substantive]
- jonatack (member) (Concept ACK, 2024-11-26): it turns out the owners of 1.2.3.4, 11.22.33.44 and 8.8.8.8, if they would bother, would know the IP address of every dev who runs the functional tests at home.
- BrandonOdiwuor (contributor) (Concept ACK, 2024-11-27): Concept ACK [not substantive]
- 0xB10C (member) (ACK, 2024-12-21) [tested]: Nice solution to use `127.0.0.1:1` as unreachable proxy for DNS requests too. I ran this on my CI runners with a 8.8.8.8 and 1.1.1.1 as DNS servers as before and the tests don't connect out now.
- sipa (member) (Concept ACK, 2024-12-23): Concept ACK [not substantive]
- fjahr (member) (Concept ACK, 2024-12-30): The changes in the tests look good but I need a little more time with the CI stuff. [not substantive]
- Sjors (member) (Concept ACK, 2025-01-13) [tested]: I tested this with https://github.com/Sjors/bitcoin/pull/76 on my own CI setup, which uses Cirrus workers configured using (roughly) the instructions here: https://github.com/bitcoin/bitcoin/blob/mast [not substantive]
- ryanofsky (member) (ACK, 2025-09-04) [read]: The new tcpdump mechanism to detect unexpected traffic is pretty simple and seems very nice.
- ryanofsky (member) (ACK, 2025-09-09) [read]: Just rebased since last review and replaced node_init_tests fix CreateSock fix with natpmp=0 fix
- ryanofsky (member) (ACK, 2025-09-29) [read]: just dropping INTERNET_TRAFFIC_EXPECTED variable since last review
- fjahr (member) (Tested ACK, 2025-09-30) [tested]: Tested again by pushing the latest version of the code with the change of the first commit commented out. I could observe the expected failure in the CI this time
- fjahr (member) (ACK, 2025-09-30) [read]: Just addressed @ryanofsky 's comments.
- ryanofsky (member) (ACK, 2025-09-30) [read]: just documenting things better since last review and adding missing exit 1 to trigger CI failure (nice find!)
- ryanofsky (member) (ACK, 2025-12-17) [read]: Since last review just rebased to avoid conflicts, added comments to commit message and test, added `local` to some bash variables
- maflcko (member) (Concept ACK, 2026-05-05): I think there is value here, re-Concept ACK, to clarify. [not substantive]
- ryanofsky (member) (ACK, 2026-09-21) [read]: Code review ACK 84bb496c6165154a64fcccd31e6ca5354531fd60. Since last review: rebased, fixed filter assignment and added local variable qualifiers. Would be good to address the `--direction` bug although the flag is harmless. Earlier concerns about running locally are resolved.
Participants:
- maflcko (member, objection, 34 statements 2024-11-22 to 2026-05-05): Concept ACKed, but raised multiple objections regarding silent error ignoring and failures when running CI locally under Podman
- laanwj (member, objection, 2 statements 2024-11-25 to 2024-11-25): Concept ACKed, but raised concerns that host background daemons could trigger false-positive CI failures
- 0xB10C (member, support, 7 statements 2024-11-26 to 2025-01-08): ACKed an earlier commit after testing with non-loopback DNS servers in CI
- 1440000bytes (contributor, support, 1 statements 2024-11-26 to 2024-11-26): Concept ACK
- jonatack (member, support, 1 statements 2024-11-26 to 2024-11-26): Concept ACK, citing privacy risks of tests leaking developer IP addresses
- BrandonOdiwuor (contributor, support, 1 statements 2024-11-27 to 2024-11-27): Concept ACK
- sipa (member, support, 2 statements 2024-12-23 to 2025-09-09): Concept ACK
- fjahr (member, objection, 8 statements 2024-12-30 to 2026-08-28): Previously tested and ACKed, but has an open objection regarding tcpdump --direction being a no-op when reading files
- fanquake (member, objection, 7 statements 2025-01-06 to 2026-06-18): Opposed merging while local CI runs under Podman fail due to outbound network traffic
- luke-jr (contributor, neutral, 1 statements 2025-01-08 to 2025-01-08): Suggested iptables UID matching
- Sjors (member, support, 1 statements 2025-01-13 to 2025-01-13): Concept ACK and tested on Cirrus workers
- ryanofsky (member, support, 13 statements 2025-09-04 to 2026-09-21): Code review ACKed latest revision, concurred --direction is a harmless no-op, previously reported a filter bug that was fixed
- sedited (member, neutral, 1 statements 2026-08-27 to 2026-08-27): Pinged reviewers for follow-up reviews
Files
79 lines under test/bench/ci.
- ci/test/03_test_script.sh +70/-0
- ci/test/00_setup_env.sh +1/-1
- ci/test/00_setup_env_mac_native.sh +2/-0
- ci/test/00_setup_env_mac_native_fuzz.sh +2/-0
- ci/test/00_setup_env_native_alpine_musl.sh +1/-1
- ci/test/02_run_container.py +1/-0
Card
The short text the ranking pass compares across PRs.
Adds automated background network monitoring via tcpdump during CI test runs to fail builds if tests generate outbound TCP or UDP packets on non-loopback interfaces or make DNS queries. Without this check, regressions can slip into tests that inadvertently leak traffic or rely on live network access. The change resolves issue #31339 and protects unit, functional, fuzz, tidy, and IWYU CI steps.
Data
thread read through 2026-09-21 (147 statements), head 84bb496c61
Discussion read under schema 1 rules: suggestions and questions may be missing, and an objection may combine several harms (schema history).
labels: Tests, Needs rebase
Categories
Build and CI
P3 · test coverage (ranking pass: Moved down from 12: valuable CI hermeticity check but no observed incident, so it ranks below concrete release and depends fixes)
This PR adds tcpdump monitoring to CI jobs to detect and fail on unexpected outbound TCP, UDP, or DNS traffic. Adding automated checks ensures test hermeticity and prevents CI runners from making external network queries.
Membership: Modifies ci/test/ scripts (00_setup_env*.sh, 02_run_container.py, 03_test_script.sh) to add tcpdump packet inspection to CI runs.
Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 0
Test infrastructure
P3 · test coverage
It enforces isolation and hermeticity across all test suites by failing if tests emit outbound packets or non-loopback DNS queries. While worthwhile for detecting tests that leak requests to the public internet, it is non-critical and reasonably deferrable.
Membership: Carries the Tests label and introduces test execution monitoring across unit, functional, and fuzz test suites to detect network leaks.
Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 0