Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(security): satisfy rustfmt + don't drop redirect guard on builder…
… failure

- peers.rs: collapse the CGNAT/private check onto one line (cargo fmt --check).
- sync.rs: replace the unwrap_or_else(reqwest::Client::new()) fallback with
  .expect(). The default client follows redirects, so the fallback silently
  reintroduced the SSRF vector Policy::none() exists to close (CodeRabbit).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
  • Loading branch information
kevincodex1 and claude committed Jun 23, 2026
commit b26bd9f9a4b801ee2499cc77fb38430caff19fe9
5 changes: 1 addition & 4 deletions crates/gitlawb-node/src/api/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ pub fn is_public_http_url(raw: &str) -> bool {
std::net::IpAddr::V4(v4) => {
let o = v4.octets();
// RFC1918 private, link-local, or CGNAT (100.64.0.0/10).
if v4.is_private()
|| v4.is_link_local()
|| (o[0] == 100 && (o[1] & 0xc0) == 64)
{
if v4.is_private() || v4.is_link_local() || (o[0] == 100 && (o[1] & 0xc0) == 64) {
return false;
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/gitlawb-node/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ async fn run(
// No redirects: peer URLs are attacker-influenceable, so a 3xx to a
// loopback/private address must not be followed (SSRF guard, matching the
// shared http_client and announce-time validation).
// Panic rather than fall back to reqwest::Client::new(): the default
// builder follows redirects, which would silently reintroduce the SSRF
// vector Policy::none() is here to close.
let client = reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap_or_else(|_| reqwest::Client::new());
.expect("failed to build no-redirect sync HTTP client");
info!("sync worker started (auto_sync=true)");
let mut interval = tokio::time::interval(std::time::Duration::from_secs(30));
loop {
Expand Down
Loading