Skip to content
New issue

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

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

Already on GitHub? # to your account

Cap maximum response length from KDC #48572

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 13 additions & 0 deletions lib/srv/desktop/rdp/rdpclient/src/network_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ impl NetworkClient {

const DEFAULT_KERBEROS_PORT: u16 = 88;

// Maximum response size from KDC we accept, Windows uses maximum token size of 48kB and recommends
// not to exceed 64kB
// https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/kerberos-authentication-problems-if-user-belongs-to-groups#calculating-the-maximum-token-size
const MAX_RESPONSE_LENGTH: u32 = 65535;

impl NetworkClient {
async fn send_tcp(&self, url: &Url, data: &[u8]) -> ConnectorResult<Vec<u8>> {
let addr = format!(
Expand All @@ -77,6 +82,14 @@ impl NetworkClient {
reason_err!("NLA", "reading data from Key Distribution Center failed")
})?;

if len > MAX_RESPONSE_LENGTH {
error!("KDC response too large: {} > {}", len, MAX_RESPONSE_LENGTH);
return Err(reason_err!(
"NLA",
"response from Key Distribution Center was too large"
));
}

let mut buf = vec![0; len as usize + 4];
buf[0..4].copy_from_slice(&(len.to_be_bytes()));

Expand Down
Loading