Some non-pgsql traffic seen by Suricata is mistankenly identified as
pgsql, as the probing function is too generic. Now, if the parser sees
an unknown message type, even if it looks like pgsql, it will fail.
Bug #6080
(cherry picked from commit
4f85d061926e870a48aeaf13bdbb4666ad7fc07e)
Self::new()
}
}
-
+
impl PgsqlState {
pub fn new() -> Self {
Self {
if input_len >= 1 && !input.is_null() {
let slice: &[u8] = build_slice!(input, input_len as usize);
- if probe_ts(slice) {
- return ALPROTO_PGSQL;
+
+ match parser::parse_request(slice) {
+ Ok((_, request)) => {
+ if let PgsqlFEMessage::UnknownMessageType(_) = request {
+ return ALPROTO_FAILED;
+ }
+ return ALPROTO_PGSQL;
+ }
+ Err(Err::Incomplete(_)) => {
+ return ALPROTO_UNKNOWN;
+ }
+ Err(_e) => {
+ return ALPROTO_FAILED;
+ }
}
}
return ALPROTO_UNKNOWN;
}
match parser::pgsql_parse_response(slice) {
- Ok((_, _response)) => {
+ Ok((_, response)) => {
+ if let PgsqlBEMessage::UnknownMessageType(_) = response {
+ return ALPROTO_FAILED;
+ }
return ALPROTO_PGSQL;
}
Err(Err::Incomplete(_)) => {