mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 02:24:17 +01:00
Merge pull request #131 from JoasASantos/fix/capability-overmint
fix(skills): stop minting held capabilities from merely reported weaknesses
This commit is contained in:
1 file changed
+149
-19
@@ -1298,30 +1298,73 @@ pub const CAPABILITIES: &[&str] = &[
|
||||
/// name, so a credential counts the same whether `default_credentials` or
|
||||
/// `sqli_union` turned it up. This is what lets the loop chain past the edges
|
||||
/// anybody declared.
|
||||
/// Whether a finding reports something the tester GOT, as opposed to a
|
||||
/// weakness they observed.
|
||||
///
|
||||
/// Seven of the nine capabilities assert possession — a credential held, a
|
||||
/// shell obtained, files read. Keyword matching alone cannot tell "RCE via the
|
||||
/// cmd parameter" from "the cmd parameter is vulnerable to command injection",
|
||||
/// and minting `rce` off the second sends privilege-escalation skills after a
|
||||
/// shell nobody has.
|
||||
///
|
||||
/// Two-sided, because hedged language and real achievement co-occur constantly
|
||||
/// — a confirmed finding's impact paragraph is usually written in "could
|
||||
/// allow" terms. An explicit achievement verb settles it; failing that, a
|
||||
/// hedge blocks. A finding marked validated has been corroborated elsewhere in
|
||||
/// the pipeline, so it passes regardless.
|
||||
fn reports_an_achievement(f: &crate::types::Finding, text: &str) -> bool {
|
||||
if f.validated {
|
||||
return true;
|
||||
}
|
||||
|
||||
const ACHIEVED: &[&str] = &[
|
||||
"achieved", "confirmed", "obtained", "recovered", "dumped", "extracted",
|
||||
"executed", "retrieved", "exfiltrated", "logged in", "authenticated as",
|
||||
"returned", "we now have", "gained", "successfully",
|
||||
];
|
||||
if ACHIEVED.iter().any(|k| text.contains(k)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const HEDGED: &[&str] = &[
|
||||
"vulnerable to", "susceptible", "potential", "possible", "may allow",
|
||||
"could allow", "would allow", "can lead to", "appears to", "risk of",
|
||||
"might", "if exploited", "an attacker could", "an attacker may",
|
||||
];
|
||||
!HEDGED.iter().any(|k| text.contains(k))
|
||||
}
|
||||
|
||||
pub fn capabilities_from(findings: &[crate::types::Finding]) -> HashSet<String> {
|
||||
let mut caps = HashSet::new();
|
||||
|
||||
for f in findings {
|
||||
let text = format!("{} {} {}", f.title, f.impact, f.evidence).to_ascii_lowercase();
|
||||
// Most capabilities assert the tester now HOLDS something, so a
|
||||
// finding that only reports the weakness must not mint them. See
|
||||
// `reports_an_achievement`.
|
||||
let achieved = reports_an_achievement(f, &text);
|
||||
|
||||
if !f.account.is_empty() && !f.secret.is_empty() {
|
||||
if achieved && !f.account.is_empty() && !f.secret.is_empty() {
|
||||
caps.insert("credential".to_string());
|
||||
}
|
||||
if ["credential", "password", "login as", "valid account", "authenticated as"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& ["credential", "password", "login as", "valid account", "authenticated as"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
{
|
||||
caps.insert("credential".to_string());
|
||||
}
|
||||
|
||||
if !f.secret.is_empty()
|
||||
|| ["api key", "api_key", "apikey", "access_token", "secret key", "private key"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& (!f.secret.is_empty()
|
||||
|| ["api key", "api_key", "apikey", "access_token", "secret key", "private key"]
|
||||
.iter().any(|k| text.contains(k)))
|
||||
{
|
||||
caps.insert("secret".to_string());
|
||||
}
|
||||
|
||||
if ["aws_access_key", "akia", "aws_secret", "service account key", "sas token",
|
||||
"gcp credential", "azure credential"].iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& ["aws_access_key", "akia", "aws_secret", "service account key", "sas token",
|
||||
"gcp credential", "azure credential"].iter().any(|k| text.contains(k))
|
||||
{
|
||||
caps.insert("cloud_token".to_string());
|
||||
caps.insert("secret".to_string());
|
||||
@@ -1335,29 +1378,33 @@ pub fn capabilities_from(findings: &[crate::types::Finding]) -> HashSet<String>
|
||||
caps.insert("endpoint".to_string());
|
||||
}
|
||||
|
||||
if ["file read", "arbitrary read", "source disclosure", "source code",
|
||||
"read /etc", "local file inclusion", "path traversal", "directory traversal"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& ["file read", "arbitrary read", "source disclosure", "source code",
|
||||
"read /etc", "local file inclusion", "path traversal", "directory traversal"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
{
|
||||
caps.insert("source_read".to_string());
|
||||
}
|
||||
|
||||
if ["remote code execution", "command execution", "code execution", "rce",
|
||||
"shell", "reverse shell", "arbitrary command"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& ["remote code execution", "command execution", "code execution", "rce",
|
||||
"shell", "reverse shell", "arbitrary command"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
{
|
||||
caps.insert("rce".to_string());
|
||||
}
|
||||
|
||||
if ["session", "account takeover", "impersonate", "hijack"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
|| !f.auth_context.is_empty()
|
||||
if achieved
|
||||
&& (["session", "account takeover", "impersonate", "hijack"]
|
||||
.iter().any(|k| text.contains(k))
|
||||
|| !f.auth_context.is_empty())
|
||||
{
|
||||
caps.insert("session".to_string());
|
||||
}
|
||||
|
||||
if ["admin", "administrator", "privilege escalation", "root access",
|
||||
"domain admin", "superuser"].iter().any(|k| text.contains(k))
|
||||
if achieved
|
||||
&& ["admin", "administrator", "privilege escalation", "root access",
|
||||
"domain admin", "superuser"].iter().any(|k| text.contains(k))
|
||||
{
|
||||
caps.insert("admin_access".to_string());
|
||||
}
|
||||
@@ -1689,3 +1736,86 @@ mod default_tests {
|
||||
assert_eq!(SkillMeta::default().max_rounds, default_max_rounds());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod overmint_tests {
|
||||
use super::*;
|
||||
|
||||
fn f(title: &str, impact: &str, evidence: &str) -> crate::types::Finding {
|
||||
let mut f = crate::types::Finding::default();
|
||||
f.agent = "a".into();
|
||||
f.title = title.into();
|
||||
f.impact = impact.into();
|
||||
f.evidence = evidence.into();
|
||||
f
|
||||
}
|
||||
|
||||
/// The bug: a finding that reports a parameter is vulnerable to command
|
||||
/// injection minted `rce`, which sends privilege-escalation and container-
|
||||
/// escape skills after a shell nobody has.
|
||||
#[test]
|
||||
fn a_reported_weakness_does_not_mint_rce() {
|
||||
let caps = capabilities_from(&[f(
|
||||
"Parameter `cmd` is vulnerable to command injection",
|
||||
"An attacker could execute arbitrary commands on the host",
|
||||
"the payload `;id` produced a 500 response",
|
||||
)]);
|
||||
assert!(!caps.contains("rce"), "a reported weakness minted rce: {caps:?}");
|
||||
}
|
||||
|
||||
/// And the finding it must not stop minting.
|
||||
#[test]
|
||||
fn a_demonstrated_shell_still_mints_rce() {
|
||||
let caps = capabilities_from(&[f(
|
||||
"Remote code execution via `cmd` parameter",
|
||||
"Full compromise of the application host",
|
||||
"executed `id`, returned: uid=33(www-data) gid=33(www-data)",
|
||||
)]);
|
||||
assert!(caps.contains("rce"), "a demonstrated shell minted nothing: {caps:?}");
|
||||
}
|
||||
|
||||
/// Hedged impact prose is normal on a confirmed finding, so an explicit
|
||||
/// achievement verb has to outweigh it.
|
||||
#[test]
|
||||
fn an_achievement_verb_outweighs_hedged_impact() {
|
||||
let caps = capabilities_from(&[f(
|
||||
"Credentials recovered from the users table",
|
||||
"An attacker could impersonate any account and may escalate to admin",
|
||||
"recovered admin:Winter2024 from the dump",
|
||||
)]);
|
||||
assert!(caps.contains("credential"), "hedged impact suppressed a real credential: {caps:?}");
|
||||
}
|
||||
|
||||
/// A finding corroborated elsewhere in the pipeline passes however it reads.
|
||||
#[test]
|
||||
fn a_validated_finding_is_taken_at_its_word() {
|
||||
let mut v = f(
|
||||
"Parameter is vulnerable to remote code execution",
|
||||
"An attacker could run arbitrary commands",
|
||||
"",
|
||||
);
|
||||
// Hedged throughout and carrying no achievement verb, so it is minted
|
||||
// only because the pipeline marked it validated.
|
||||
assert!(
|
||||
!capabilities_from(std::slice::from_ref(&v)).contains("rce"),
|
||||
"fixture must be blocked when unvalidated, or the test proves nothing",
|
||||
);
|
||||
v.validated = true;
|
||||
assert!(capabilities_from(&[v]).contains("rce"));
|
||||
}
|
||||
|
||||
/// Disclosure capabilities state what was revealed, not what was seized,
|
||||
/// so hedging must not gate them.
|
||||
#[test]
|
||||
fn disclosure_capabilities_are_not_gated_by_hedging() {
|
||||
let caps = capabilities_from(&[f(
|
||||
"Verbose error may disclose internal topology",
|
||||
"An attacker could map the internal network",
|
||||
"connection refused to 10.42.7.19:5432",
|
||||
)]);
|
||||
assert!(
|
||||
caps.contains("internal_host"),
|
||||
"hedging suppressed a disclosed host, which was observed not claimed: {caps:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user