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

Fix potential DoS with responding to responses #247

Merged
merged 1 commit into from
Jun 2, 2023
Merged
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
13 changes: 12 additions & 1 deletion bin-resolved/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ async fn handle_raw_message<'a>(args: ListenArgs, buf: &[u8]) -> Option<Message>
match res {
Ok(msg) => {
if msg.header.is_response {
Some(Message::make_format_error_response(msg.header.id))
// Do not respond to response messages: this is because an
// inbound message could spoof its source address / port to
// match resolved's, and so make it respond to itself, which
// triggers another response, etc
//
// See #246
None
} else if msg.header.opcode == Opcode::Standard {
Some(resolve_and_build_response(args, msg).await)
} else {
Expand All @@ -159,6 +165,11 @@ async fn handle_raw_message<'a>(args: ListenArgs, buf: &[u8]) -> Option<Message>
Some(response)
}
}

// An attacker could craft an incomplete message with the source address
// / port being resolved's, which would make resolved respond to itself
// here, but this is fine so long as (1) the response we send is valid
// and (2) we don't reply to a valid message which is a response.
Err(err) => err.id().map(Message::make_format_error_response),
}
}
Expand Down