Skip to content
Snippets Groups Projects

Implement a "lightweight" form of pathbias detection.

Closed Nick Mathewson requested to merge nickm/arti:pb_lite into main
3 unresolved threads

We now track, for every guard: the total number of successful circuits we've built through it, along with the total number of "indeterminate" circuits.

Recall that a circuit's status is "indeterminate" if it has failed for a reason that might be the guard's fault, or might not be the guard's fault. For example, if extending to the second hop of the circuit fails, we have no way to know whether the guard deliberately refused to connect there, or whether the second hop is just offline.

But we don't want to forgive all indeterminate circuit failures: if we did, then a malicious guard could simply reject any second hops that it didn't like, thereby filtering the client into a chosen set of circuits.

As a stopgap solution, this patch now makes guards become permanently disabled if the fraction of their circuit failures becomes too high.

See also general-purpose path bias selection (#65 (closed)), and Mike's idea for changing the guard reachability definition (torspec#67). This patch doesn't do either of those.

Closes #185 (closed).

Edited by Nick Mathewson

Merge request reports

Approved by

Closed by Nick MathewsonNick Mathewson 3 years ago (Oct 26, 2021 4:05pm UTC)

Merge details

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • eta
  • eta
  • eta
  • eta
  • Contributor

    apart from a few minor nits, this looks like it's generally going in the right direction! feel free to request review again when it gets out of draft status :)

  • Nick Mathewson added 3 commits

    added 3 commits

    • 4b2fad19 - fixup! Do not blame a guard for failures on non-random circuits.
    • 27a19b89 - Avoid a strange borrow syntax in tor_guardmgr::sample
    • 4ae2ca56 - fixup! Implement a "lightweight" form of pathbias detection.

    Compare with previous version

  • Thanks for the review! I've added a few more commits to the branch.

    Do you generally prefer that I squash fixup! comments like this before requesting review again, or only before merging?

  • Nick Mathewson marked this merge request as ready

    marked this merge request as ready

  • eta
    eta @eta started a thread on the diff
  • 496 498 const WARN_THRESHOLD: f64 = 0.5;
    497 499
    498 500 if ratio > DISABLE_THRESHOLD {
    499 let reason = format!("{:.1}% of circuits died under mysterious circumstances, exceeding threshold of {:.1}%", ratio*100.0, (DISABLE_THRESHOLD*100.0));
    500 warn!(guard=?self.id, "Disabling guard: {}", reason);
    501 let reason = GuardDisabled::TooManyIndeterminateFailures {
    502 history: self.circ_history.clone(),
    503 failure_ratio: ratio,
    504 threshold_ratio: DISABLE_THRESHOLD,
    505 };
    506 warn!(guard=?self.id, "Disabling guard: {:.1}% of circuits died under mysterioius circumstances, exceeding threshold of {:.1}%", ratio*100.0, (DISABLE_THRESHOLD*100.0));
  • eta
    eta @eta started a thread on the diff
  • 535 541 }
    536 542 }
    537 543
    544 /// A reason for permanently disabling a guard.
    545 #[derive(Clone, Debug, Serialize, Deserialize)]
    546 #[serde(tag = "type")]
    547 enum GuardDisabled {
  • eta
    eta @eta started a thread on the diff
  • 952 975 assert!(g.disabled.is_some());
    953 assert_eq!(
    954 &g.disabled.unwrap(),
    955 "93.3% of circuits died under mysterious circumstances, exceeding threshold of 70.0%"
    956 );
    976
    977 if let GuardDisabled::TooManyIndeterminateFailures {
    978 history: _,
    979 failure_ratio,
    980 threshold_ratio,
    981 } = g.disabled.unwrap()
    982 {
    983 assert!((failure_ratio - 0.933).abs() < 0.01);
    984 assert!((threshold_ratio - 0.7).abs() < 0.01);
    985 } else {
    986 panic!("Wrong variant.")
    • Contributor

      maybe actually include the wrong value with {:?} so if this ever fires you get an idea of what the wrong variant is?

      (might need to make this a match statement to do so)

    • Please register or sign in to reply
  • eta approved this merge request

    approved this merge request

  • Contributor

    lgtm modulo minor nits that don't necessitate a further round of review in my opinion :p

    Do you generally prefer that I squash fixup! comments like this before requesting review again, or only before merging?

    How I looked at what you'd changed since requesting review was going to the "changes" tab and doing this:

    image

    This mechanism seems to work irrespective of whether you squashed or not, because I force-pushed in !102 (closed) and it still seems to work there. So basically, I don't have any preference — do whatever you think is easiest, as long as you actually remember to squash before merging that is :)

  • Fixed nits, squashed, and merged!

  • Please register or sign in to reply
    Loading