ragleap-security 0.3.0
Design: #1506. One new module, ragleap_security.net; nothing from 0.2.0 changed, so there are no behaviour changes and every 0.2.0 name still works. It is standard library only and is imported on its own (from ragleap_security.net import ...).
Added
ragleap_security.net:SafeFetcher,FetchPolicy,FetchResult,NetError,address_allowed. Outbound HTTP (GET and HEAD) that is safe by default and per tenant. On every request and every redirect hop it applies strict URL parsing (https only unless the policy allows http; no userinfo, no number-like hosts such as2130706433or0x7f.1, no IP literals, ASCII only), a host allowlist from the tenant's own policy (deny by default; a missing, wrong-typed or failing policy refuses), one DNS lookup whose EVERY address must pass the address rule, and a connection to the checked address (the name is never resolved twice, so DNS rebinding does not work). The address rule unwraps an embedded IPv4 (IPv4-mapped, NAT64, 6to4) and then allows only global addresses outside an explicit blocklist (verified on Python 3.10.20 and 3.12.3: theipaddressflags for mapped addresses differ between versions, and multicast, NAT64 and IPv4-compatible forms can reportis_global). Redirects are followed by this module only, with the caller's headers sent to the first origin and never again after leaving it. One monotonic deadline covers connect, TLS and reading; the body is capped and refused (never truncated);Accept-Encoding: identityis sent and any content encoding is refused; no proxy or.netrcfrom the environment; TLS verification is always on (system CA store, TLS 1.2 or newer). Every refusal is one fixed reason code. OptionalAuditLog(net.request,net.redirect,net.blocked: scope, host, port, status, byte count, hop count, reason; never the path, query, headers or body; a failed write raises) andRateLimiter(per scope, before any lookup).tests/test_net.py(258 tests) with a local server; only the DNS answer and the connection target use a documented, underscore-named test seam (loopback is blocked by design).tests/test_hostile_tenant.py(28 tests; merged earlier, no code change): attacks a hostile tenant would try against scope keys, rate limits, the audit log and secret wrappers.- 46 more mutations in
scripts/mutation_check.pyfor the net module (181 in total, all killed on Python 3.10 and 3.12). The net mutations run againsttests/test_net.pyonly, andpython scripts/mutation_check.py net:runs just them. The first run found 5 survivors: missing tests (the unwrapping of mapped addresses was only caught on Python versions whose flags disagree, the four-tries cap, the deadline between reads and between hops) and one redundant explicitclose(), which was removed.
Does not defend
- A host on the allowlist is trusted: a compromised allowed host, or one that redirects to another allowed host, is followed.
- A DNS answer that is consistently wrong (an allowed name pointed at an attacker's public server) is not detected. A slow DNS server can exceed the deadline before the check happens (the lookup cannot be interrupted).
- TLS certificate-authority compromise; local tampering with the hosts file or resolver settings.
- The response is untrusted data: mark steps that fetch as
external(tainting) in flows and agents. - Non-HTTP egress; internal services on private names (refused by design, there is no
allow_private); POST and other methods; IDN names must be given as punycode. - Windows and macOS are not tested; no independent security review.
Not verified
Real traffic to the public internet and a real TLS handshake with a valid certificate (the tests use a local plain-HTTP server and check the TLS settings directly); IPv6-only networks; Windows and macOS.
Verified (after publishing)
- Both file hashes match the PyPI JSON.
- The wheel's
.pyfiles are identical to the source at the tag. - Plain and
[crypto]installs in clean environments; the 614 tests from the source archive pass against the installed wheel. - An attack check on the published wheel refused 169.254.169.254,
64:ff9b::a9fe:a9fe,::127.0.0.1,::ffff:10.0.0.1,fd00::1and100.64.0.1. - Provenance of both files decoded and matched.
Provenance
- PyPI upload: 2026-11-23 11:05 UTC. Tag
ragleap-security-v0.3.0on commitaa305865be48742a6f7d83b1eea6125d16dedff2. - Wheel sha256
6a9c5a6c162e1c0759ab6731fe48ef441bc505b0a564c77fb5d31554c9b9b37d - Source archive sha256
619b13a362858d301f4e30e92577fb8a95a1bed3a03ff0a214a5da8cdc3b52e8 - Both files carry a PyPI provenance record: publisher GitHub
ragleap/ragleap-core, workflowrelease.yml, environmentpypi; the digests match. - No independent security review has been done.