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

detect/krb5: avoid integer underflow with krb5.ticket_encryption #12598

Closed
Closed
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 rust/src/krb/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ pub fn detect_parse_encryption_list(i: &str) -> IResult<&str, DetectKrb5TicketEn
let (i, v) = many1(detect_parse_encryption_item)(i)?;
for &val in v.iter() {
let vali = val.0;
if vali < 0 && ((-vali) as usize) < KRB_TICKET_FASTARRAY_SIZE {
// KRB_TICKET_FASTARRAY_SIZE is a constant typed usize but which fits in a i32
if vali < 0 && vali > -(KRB_TICKET_FASTARRAY_SIZE as i32) {
l.negative[(-vali) as usize] = true;
} else if vali >= 0 && (vali as usize) < KRB_TICKET_FASTARRAY_SIZE {
l.positive[vali as usize] = true;
Expand Down Expand Up @@ -326,5 +327,15 @@ mod tests {
panic!("Result should have been ok.");
}
}
let ctx = detect_parse_encryption("-2147483648").unwrap().1;
match ctx {
DetectKrb5TicketEncryptionData::LIST(l) => {
assert_eq!(l.other.len(), 1);
assert_eq!(l.other[0], EncryptionType(i32::MIN));
}
_ => {
panic!("Result should have been list.");
}
}
}
}
Loading