Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hs: Don't overwrite DoS parameters on circuit with consensus params #2069

Open
wants to merge 1 commit into
base: maint-0.4.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions changes/ticket40109
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
o Major bugfixes (onion services, DoS):
- The consensus parameters for the onion service DoS defenses was
overwriting the circuit parameters that could have been set by the service
operator using HiddenServiceEnableIntroDoSDefense. Fixes bug 40109; bugfix
on 0.4.2.1-alpha.

4 changes: 4 additions & 0 deletions src/core/or/or_circuit_st.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ struct or_circuit_t {
/** If set, the DoS defenses are enabled on this circuit meaning that the
* introduce2_bucket is initialized and used. */
unsigned int introduce2_dos_defense_enabled : 1;
/** If set, the DoS defenses were explicitly enabled through the
* ESTABLISH_INTRO cell extension. If unset, the consensus is used to learn
* if the defenses can be enabled or not. */
unsigned int introduce2_dos_defense_explicit : 1;

/** INTRODUCE2 cell bucket controlling how much can go on this circuit. Only
* used if this is a service introduction circuit at the intro point
Expand Down
5 changes: 5 additions & 0 deletions src/feature/hs/hs_dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ update_intro_circuits(void)
smartlist_t *intro_circs = hs_circuitmap_get_all_intro_circ_relay_side();

SMARTLIST_FOREACH_BEGIN(intro_circs, circuit_t *, circ) {
/* Ignore circuit if the defenses were set explicitly through the
* ESTABLISH_INTRO cell DoS extension. */
if (TO_OR_CIRCUIT(circ)->introduce2_dos_defense_explicit) {
continue;
}
/* Defenses might have been enabled or disabled. */
TO_OR_CIRCUIT(circ)->introduce2_dos_defense_enabled =
consensus_param_introduce_defense_enabled;
Expand Down
5 changes: 5 additions & 0 deletions src/feature/hs/hs_intropoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ handle_establish_intro_cell_dos_extension(
}
}

/* At this point, the extension is valid so any values out of it implies
* that it was set explicitly and thus flag the circuit that it should not
* look at the consensus for that reason for the defenses' values. */
circ->introduce2_dos_defense_explicit = 1;

/* A value of 0 is valid in the sense that we accept it but we still disable
* the defenses so return false. */
if (intro2_rate_per_sec == 0 || intro2_burst_per_sec == 0) {
Expand Down