Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.
Rust ai-agentsclaude-codeclaude-code-pluginclicodexcursordevsecopsmcposvowasprustsastsecret-scanningsecretssecuritysecurity-scannersql-injectionvulnerabilityvulnerability-scannerxss
fix(config): weak-tls-version reads the signs on Apache SSLProtocol (#129)
Pure Tech5c2c859895ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3b4b626..8f48a11 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,10 @@checked". A larger one is named in the report (`lockfiles_too_large` in JSON). npm, Composer and Pipfilelockfiles are also read in one pass, whatever their key order: 0.12 s instead of 4.3 s for a 3 MBpackage-lock.json, 0.5 s for 60 MB.+- Config: `config.weak-tls-version` reads Apache's `SSLProtocol` signs, so `all -SSLv3 -TLSv1 -TLSv1.1` is no+ longer reported, while `all -SSLv3` (TLS 1.0 still on) and `+TLSv1.1` still are. A plain name replaces the set+ so far, as Apache does, so `TLSv1.2 TLSv1` is reported and `TLSv1 TLSv1.2` is not. A line that names an old+ version and goes on after a backslash, uses a `${VAR}` or has an unknown word is still reported.## 1.1.0 (2026-11-25)diff --git a/src/rules/config.rs b/src/rules/config.rsindex 5ce46f9..ae3f0bd 100644--- a/src/rules/config.rs+++ b/src/rules/config.rs@@ -207,7 +207,7 @@ pub static RULES: &[Rule] = &["config.weak-tls-version",Medium,server_conf,- r"(?i)(?:ssl_protocols|SSLProtocol)[^;\n]*\b(?:SSLv[23]|TLSv1|TLSv1\.1)(?:\s|;|$)",+ r#"(?i)(?:ssl_protocols|SSLProtocol)[^;\n]*\b(?:SSLv[23]|TLSv1|TLSv1\.1)(?:\s|;|$|["'])"#,None,"Old TLS or SSL versions are enabled; they have known attacks.","Allow only TLSv1.2 and TLSv1.3."@@ -417,14 +417,101 @@ pub fn keep(file: &FileInfo, text: &Text, f: &Finding, hcl: &mut HclWalk) -> boo.is_some_and(is_public_access_block)})}+ "config.weak-tls-version" => old_tls_on(text.line(f.line)),_ => true,}}+/// Whether an Apache `SSLProtocol` line leaves an old version on. Its words are applied in+/// order: `all` turns every version on, `-name` turns one off, and `+name` turns it on, so+/// `all -SSLv3 -TLSv1 -TLSv1.1` is safe while `all -SSLv3` still allows TLS 1.0. A plain name+/// (or a plain `all`) replaces the set so far, as mod_ssl does, so `TLSv1 TLSv1.2` leaves only+/// TLS 1.2 on. Any other line, such as nginx `ssl_protocols` (no signs), is kept as the pattern+/// found it, and so is one that this line alone cannot settle: it goes on after a trailing+/// backslash, uses a `${VAR}`, or has a word that is not a known protocol. Quotes around words+/// are dropped, as in Apache.+fn old_tls_on(line: &str) -> bool {+ const OLD: [&str; 4] = ["sslv2", "sslv3", "tlsv1", "tlsv1.1"];+ let lower = line.to_ascii_lowercase();+ let mut words = lower.split_whitespace();+ if words.next() != Some("sslprotocol") {+ return true;+ }+ if lower.trim_end().ends_with('\\') || lower.contains("${") {+ return true;+ }+ // Only the known names are tracked, so a long line costs one pass; an unknown word keeps the finding.+ const KNOWN: [&str; 6] = ["sslv2", "sslv3", "tlsv1", "tlsv1.1", "tlsv1.2", "tlsv1.3"];+ let mut on: Vec<&str> = Vec::new();+ for word in words {+ let word = word.trim_matches(|c| c == '"' || c == '\'');+ if word.contains(['"', '\'']) {+ return true;+ }+ let (add, name) = match word.strip_prefix('-') {+ Some(name) => (false, name),+ None => (true, word.strip_prefix('+').unwrap_or(word)),+ };+ if name != "all" && !KNOWN.contains(&name) {+ return true;+ }+ // A plain name (no sign) replaces the set so far, as mod_ssl does.+ if !word.starts_with(['+', '-']) {+ on.clear();+ }+ let names = if name == "all" {+ &OLD[1..]+ } else {+ std::slice::from_ref(&name)+ };+ for &n in names {+ on.retain(|&o| o != n);+ if add {+ on.push(n);+ }+ }+ }+ on.iter().any(|n| OLD.contains(n))+}+#[cfg(test)]mod tests {use super::*;+ #[test]+ fn sslprotocol_minus_turns_a_version_off() {+ for (line, on) in [+ ("SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1", false),+ (" sslprotocol ALL -sslv3 -tlsv1 -tlsv1.1", false),+ ("SSLProtocol -all +TLSv1.2 +TLSv1.3", false),+ ("SSLProtocol all -SSLv3", true),+ ("SSLProtocol all -SSLv3 -TLSv1", true),+ ("SSLProtocol -all +TLSv1.1 +TLSv1.2", true),+ // A plain name replaces the set so far, as mod_ssl does: only TLSv1.2 is on.+ ("SSLProtocol TLSv1 TLSv1.2", false),+ ("SSLProtocol TLSv1.2 TLSv1", true),+ ("SSLProtocol TLSv1.2 +TLSv1.1", true),+ // An unknown word cannot be weighed, so the finding stays.+ ("SSLProtocol -all +TLSv1.2 bogus", true),+ ("SSLProtocol -TLSv1 all", true),+ // Apache removes argument quotes before reading the words.+ ("SSLProtocol \"all\" \"-SSLv3\" '-TLSv1' -TLSv1.1", false),+ ("SSLProtocol \"all -SSLv3\"", true),+ // Quotes that run two words together cannot be split safely here.+ ("SSLProtocol \"-all\"\"+TLSv1.2\"", true),+ // A line that goes on after a backslash, or a ${VAR}, is not read in full here.+ ("SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 \\", true),+ ("SSLProtocol ${LEGACY} -SSLv3 -TLSv1 -TLSv1.1", true),+ ("ssl_protocols TLSv1 TLSv1.2;", true),+ (+ "ssl_protocols TLSv1 TLSv1.2; # like SSLProtocol in Apache",+ true,+ ),+ ] {+ assert_eq!(old_tls_on(line), on, "{line}");+ }+ }+/// Whether the first `key = false` in `src` is reported: it matches and sits in an S3/// public access block.fn in_block(src: &str) -> bool {diff --git a/tests/fixtures/config/EXPECTED b/tests/fixtures/config/EXPECTEDindex acc7949..4fe3d39 100644--- a/tests/fixtures/config/EXPECTED+++ b/tests/fixtures/config/EXPECTED@@ -21,6 +21,11 @@ infra/main.tf:3 config.tf-open-ingressinfra/main.tf:6 config.tf-public-bucketinfra/main.tf:34 config.tf-public-databaseinfra/main.tf:35 config.tf-unencrypted-storage+apache/site.conf:8 config.weak-tls-version+apache/site.conf:11 config.weak-tls-version+apache/site.conf:17 config.weak-tls-version+apache/site.conf:21 config.weak-tls-version+apache/site.conf:27 config.weak-tls-versioninfra/main.tf:11 config.tf-public-access-blockinfra/main.tf:13 config.tf-public-access-blockinfra/main.tf:17 config.tf-public-access-blockdiff --git a/tests/fixtures/config/apache/site.conf b/tests/fixtures/config/apache/site.confnew file mode 100644index 0000000..827e249--- /dev/null+++ b/tests/fixtures/config/apache/site.conf@@ -0,0 +1,28 @@+<VirtualHost *:443>+ SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1+</VirtualHost>+<VirtualHost *:8443>+ SSLProtocol -all +TLSv1.2 +TLSv1.3+</VirtualHost>+<VirtualHost *:9443>+ SSLProtocol all -SSLv3+</VirtualHost>+<VirtualHost *:10443>+ SSLProtocol -all +TLSv1.1 +TLSv1.2+</VirtualHost>+<VirtualHost *:11443>+ SSLProtocol TLSv1 TLSv1.2+</VirtualHost>+<VirtualHost *:12443>+ SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 \+ +TLSv1+</VirtualHost>+<VirtualHost *:13443>+ SSLProtocol ${LEGACY} -SSLv3+</VirtualHost>+<VirtualHost *:14443>+ SSLProtocol "all" "-SSLv3" "-TLSv1" "-TLSv1.1"+</VirtualHost>+<VirtualHost *:15443>+ SSLProtocol "-all" "+TLSv1"+</VirtualHost>