forked from greenbone/openvas-scanner
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: nasl-cli/openvasd: possible stackoverflow on End::Continue
When a NASL script gets executed a lot of parens that includes SyntaxError then nasl-cli may get stuck in an recursive loop that overflows the stack therefore it was reported with the severity `VSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:L/SA:H`. To fix it Lexer rembers it's current depth and when it get higher than the defined MAX_DEPTH it returns an SyntaxError of kind MaxRecursion. If it is based on an previous error then the iterator implementation of Lexer simulates an EoF to prevent multiple false positive errors to be reported.
- Loading branch information
1 parent
c482c2f
commit a4cbe5e
Showing
5 changed files
with
78 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
i~f&((((((((((((((((((((((((((((((((+(((((((((((re(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((~f&((((((((((((((((((((((((((((((((+(((((((((((re(((((((((((((((((((((((((((((((((((((((((((((((((((((~f&((((((((((((((((((((((((((((((((+(((((((((((re((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((~f&((((((((((((((((((((((((((((((((+(((((((((((re(((((((((((,i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-FileCopyrightText: 2023 Greenbone AG | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#[cfg(test)] | ||
mod test { | ||
|
||
use nasl_syntax::{logger::NaslLogger, parse}; | ||
|
||
#[test] | ||
fn validate_recursion_depth_to_prevent_stackoverflow() { | ||
// Reported by Anon, VSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:L/SA:H | ||
// Crash due to depth limit on recursion. | ||
let code = include_str!("crash-recursion-depth.nasl"); | ||
assert_eq!(code.len(), 587); | ||
let result = nasl_syntax::parse(code).collect::<Vec<_>>(); | ||
assert_eq!(result.len(), 1); | ||
assert!(result[0].is_err()) | ||
} | ||
} |