fix(owasp): tag probes with the OWASP LLM Top 10 2025 ids

OWASP_LLM_TOP_10 used the 2023/24 v1.1 numbering while the badge links to the project, whose current list is the 2025 edition (https://genai.owasp.org/llm-top-10/). DataLeak now tags LLM02 Sensitive Information Disclosure, Malwaregen LLM05 Improper Output Handling, AgenticBackend LLM06 Excessive Agency, Hallucination and refuse-to-answer LLM09 Misinformation. The harness already uses LLM01:2025.
This commit is contained in:
John B Joseph committed 2026-11-13 07:41:51 +05:30
1 parent 5aee9da60f
commit 6495c671b2
2 files changed
+46 -22

No files matched your search

+14 -16
View File
@@ -10,33 +10,31 @@ handful of purpose-built local probes (data leak, hallucination, agentic,
malware) map to their own categories.
"""
# OWASP Top 10 for LLM Applications (2023/2024 numbering).
# OWASP Top 10 for LLM Applications 2025 (https://genai.owasp.org/llm-top-10/).
OWASP_LLM_TOP_10 = {
"LLM01": "Prompt Injection",
"LLM02": "Insecure Output Handling",
"LLM03": "Training Data Poisoning",
"LLM04": "Model Denial of Service",
"LLM05": "Supply Chain Vulnerabilities",
"LLM06": "Sensitive Information Disclosure",
"LLM07": "Insecure Plugin Design",
"LLM08": "Excessive Agency",
"LLM09": "Overreliance",
"LLM10": "Model Theft",
"LLM02": "Sensitive Information Disclosure",
"LLM03": "Supply Chain",
"LLM04": "Data and Model Poisoning",
"LLM05": "Improper Output Handling",
"LLM06": "Excessive Agency",
"LLM07": "System Prompt Leakage",
"LLM08": "Vector and Embedding Weaknesses",
"LLM09": "Misinformation",
"LLM10": "Unbounded Consumption",
}
OWASP_PROJECT_URL = (
"https://owasp.org/www-project-top-10-for-large-language-model-applications/"
)
OWASP_PROJECT_URL = "https://genai.owasp.org/llm-top-10/"
_DEFAULT_CATEGORY = "LLM01"
# Datasets whose intent doesn't match the prompt-injection default. Keyed by the
# lowercased dataset name (or a substring of it).
_NAME_OVERRIDES = {
"dataleak": "LLM06",
"dataleak": "LLM02",
"hallucination": "LLM09",
"malwaregen": "LLM02",
"agenticbackend": "LLM08",
"malwaregen": "LLM05",
"agenticbackend": "LLM06",
"refuse-to-answer": "LLM09",
}
+32 -6
View File
@@ -1,3 +1,5 @@
import pytest
from agentic_security.probe_data import REGISTRY
from agentic_security.probe_data.owasp import (
OWASP_LLM_TOP_10,
@@ -13,18 +15,42 @@ def test_classify_defaults_to_prompt_injection():
assert classify({}) == "LLM01"
def test_classify_overrides():
assert classify({"dataset_name": "DataLeak"}) == "LLM06"
assert classify({"dataset_name": "Hallucination"}) == "LLM09"
assert classify({"dataset_name": "Malwaregen"}) == "LLM02"
assert classify({"dataset_name": "AgenticBackend"}) == "LLM08"
def test_top_10_matches_2025_list():
# https://genai.owasp.org/llm-top-10/
assert OWASP_LLM_TOP_10 == {
"LLM01": "Prompt Injection",
"LLM02": "Sensitive Information Disclosure",
"LLM03": "Supply Chain",
"LLM04": "Data and Model Poisoning",
"LLM05": "Improper Output Handling",
"LLM06": "Excessive Agency",
"LLM07": "System Prompt Leakage",
"LLM08": "Vector and Embedding Weaknesses",
"LLM09": "Misinformation",
"LLM10": "Unbounded Consumption",
}
@pytest.mark.parametrize(
"dataset_name, expected_id, expected_title",
[
("DataLeak", "LLM02", "Sensitive Information Disclosure"),
("Hallucination", "LLM09", "Misinformation"),
("Malwaregen", "LLM05", "Improper Output Handling"),
("AgenticBackend", "LLM06", "Excessive Agency"),
("notrichardren/refuse-to-answer-prompts", "LLM09", "Misinformation"),
],
)
def test_classify_overrides(dataset_name, expected_id, expected_title):
assert classify({"dataset_name": dataset_name}) == expected_id
assert owasp_tag({"dataset_name": dataset_name})["title"] == expected_title
def test_owasp_tag_shape():
tag = owasp_tag({"dataset_name": "Hallucination"})
assert tag["id"] == "LLM09"
assert tag["title"] == OWASP_LLM_TOP_10["LLM09"]
assert tag["url"].startswith("https://owasp.org/")
assert tag["url"] == "https://genai.owasp.org/llm-top-10/"
def test_annotate_covers_every_registry_entry():