aisvs-scanner 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aisvs_scanner-1.0.0/LICENSE +176 -0
- aisvs_scanner-1.0.0/PKG-INFO +413 -0
- aisvs_scanner-1.0.0/README.md +388 -0
- aisvs_scanner-1.0.0/pyproject.toml +42 -0
- aisvs_scanner-1.0.0/setup.cfg +4 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/__init__.py +19 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/__main__.py +6 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/analyzers/__init__.py +4 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/analyzers/artifact.py +162 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/analyzers/mcp_config.py +185 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/analyzers/taint.py +322 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/catalog.py +150 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/cli.py +193 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/data/aisvs-1.01.json +2147 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/data/aisvs-1.02-dev.json +2147 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/engine.py +283 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/models.py +162 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/profile.py +131 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/__init__.py +16 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/csv_rep.py +36 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/html_rep.py +708 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/json_rep.py +12 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/markdown.py +68 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/sarif.py +82 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/reporters/terminal.py +120 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/__init__.py +20 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/base.py +163 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/r_agents_mcp.py +191 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/r_io_access.py +143 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/r_model_infra.py +155 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/rules/r_rag_robust_monitor.py +118 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/util.py +52 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner/walker.py +157 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner.egg-info/PKG-INFO +413 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner.egg-info/SOURCES.txt +38 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner.egg-info/dependency_links.txt +1 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner.egg-info/entry_points.txt +2 -0
- aisvs_scanner-1.0.0/src/aisvs_scanner.egg-info/top_level.txt +1 -0
- aisvs_scanner-1.0.0/tests/test_cli_reporters.py +104 -0
- aisvs_scanner-1.0.0/tests/test_scanner.py +181 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aisvs-scanner
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A full-fledged security verification scanner for the OWASP Artificial Intelligence Security Verification Standard (AISVS)
|
|
5
|
+
Author-email: Mesut Güngör <clietech@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/mesutgungor/aisvs_scanner
|
|
8
|
+
Project-URL: Repository, https://github.com/mesutgungor/aisvs_scanner
|
|
9
|
+
Project-URL: Issues, https://github.com/mesutgungor/aisvs_scanner/issues
|
|
10
|
+
Keywords: owasp,aisvs,ai-security,llm-security,mcp-security,rag,agents,sast
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Information Technology
|
|
14
|
+
Classifier: Topic :: Security
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
<div align="center">
|
|
27
|
+
|
|
28
|
+
# 🛡️ OWASP AISVS Scanner (`aisvs-scan`)
|
|
29
|
+
|
|
30
|
+
**Enterprise-Grade Static Security Verification & Compliance Auditor for AI Systems, Autonomous Agents, and Model Context Protocol (MCP)**
|
|
31
|
+
|
|
32
|
+
[](https://github.com/OWASP/AISVS)
|
|
33
|
+
[](https://www.python.org/)
|
|
34
|
+
[](LICENSE)
|
|
35
|
+
[-brightgreen?style=for-the-badge)](#)
|
|
36
|
+
[](https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning)
|
|
37
|
+
[](#testing)
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="#key-capabilities">Key Capabilities</a> •
|
|
41
|
+
<a href="#architecture">Architecture</a> •
|
|
42
|
+
<a href="#quickstart">Quickstart</a> •
|
|
43
|
+
<a href="#chapter-coverage">12 AISVS Chapters</a> •
|
|
44
|
+
<a href="#interactive-html-dashboard">Interactive Dashboard</a> •
|
|
45
|
+
<a href="#cli-reference">CLI Reference</a> •
|
|
46
|
+
<a href="#cicd-integration">CI/CD Integration</a> •
|
|
47
|
+
<a href="#case-study">Real-World Benchmark</a>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Executive Overview
|
|
55
|
+
|
|
56
|
+
The **[OWASP Artificial Intelligence Security Verification Standard (AISVS)](https://github.com/OWASP/AISVS)** establishes a comprehensive, vendor-neutral baseline of security requirements for modern AI applications, machine learning systems, autonomous agent swarms, and foundation model integrations.
|
|
57
|
+
|
|
58
|
+
`aisvs-scan` is a static application security testing (SAST) and compliance verification engine purpose-built for the AI era. It inspects source code, prompt hierarchies, tool manifests, MCP client/server topologies, and serialized model artifacts directly against the official AISVS catalog, evaluating requirements across **Levels 1, 2, and 3**.
|
|
59
|
+
|
|
60
|
+
Unlike legacy SAST tools that only identify generic injection vulnerabilities, `aisvs-scan` understands **AI-native threat vectors**:
|
|
61
|
+
- Model Context Protocol (MCP) server impersonation, DNS rebinding, unpinned tool runners, and form-mode secret elicitation.
|
|
62
|
+
- Agent tool execution without process isolation, sandbox escapes, and auto-approval bypasses on destructive actions.
|
|
63
|
+
- Model output flow into dangerous command, SQL, file, or network execution sinks (AI Taint Tracking).
|
|
64
|
+
- System/developer prompt contamination and instruction hierarchy degradation.
|
|
65
|
+
- Weaponized serialization opcodes embedded within PyTorch, Pickle, and Joblib model weights.
|
|
66
|
+
- Unauthenticated vector databases, cross-tenant embedding collisions, and missing retrieval authorization filters in RAG pipelines.
|
|
67
|
+
|
|
68
|
+
> ⚡ **Zero Third-Party Dependencies:** Implemented strictly using the Python Standard Library (`ast`, `re`, `pickle`, `urllib`, `dataclasses`, `argparse`). Installs instantaneously and runs hermetically in air-gapped or restricted CI environments.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Key Capabilities
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
76
|
+
│ OWASP AISVS SCANNER │
|
|
77
|
+
├───────────────────────────────┬────────────────────────────────────────┤
|
|
78
|
+
│ 🎯 214 AISVS Requirements │ 100% coverage of official AISVS 1.01 │
|
|
79
|
+
│ │ and 1.02-dev standard specifications. │
|
|
80
|
+
├───────────────────────────────┼────────────────────────────────────────┤
|
|
81
|
+
│ 🔬 4 Specialized Engines │ AST Taint Tracker, MCP Config Auditor, │
|
|
82
|
+
│ │ Model Weights Disassembler, & Rules. │
|
|
83
|
+
├───────────────────────────────┼────────────────────────────────────────┤
|
|
84
|
+
│ 🛡️ Multi-Verdict Auditing │ PASS (verified defense), FAIL (flaw), │
|
|
85
|
+
│ │ GAP (missing), MANUAL, and N/A. │
|
|
86
|
+
├───────────────────────────────┼────────────────────────────────────────┤
|
|
87
|
+
│ 🧩 Component Profiling │ Automatic detection of LLMs, Agents, │
|
|
88
|
+
│ │ RAG, MCP, Fine-Tuning, & Edge AI. │
|
|
89
|
+
├───────────────────────────────┼────────────────────────────────────────┤
|
|
90
|
+
│ 📊 6 Enterprise Reports │ Interactive HTML, SARIF 2.1.0, JSON, │
|
|
91
|
+
│ │ Terminal ANSI, Markdown, & GRC CSV. │
|
|
92
|
+
└───────────────────────────────┴────────────────────────────────────────┘
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Architecture & Detection Engines
|
|
98
|
+
|
|
99
|
+
`aisvs-scan` uses a hybrid analysis pipeline combining syntax parsing, abstract syntax tree (AST) data-flow tracking, configuration auditing, and binary serialization inspection.
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Target Repository / AI Project
|
|
103
|
+
│
|
|
104
|
+
[File Walker & Lang Router]
|
|
105
|
+
│
|
|
106
|
+
┌──────────────────┬──────────────┴─────┬──────────────────┐
|
|
107
|
+
▼ ▼ ▼ ▼
|
|
108
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
109
|
+
│ AST Taint │ │ MCP Config │ │ Artifact │ │ Declarative │
|
|
110
|
+
│ Tracker │ │ Auditor │ │ Disassembler │ │ Rule Engine │
|
|
111
|
+
│ (Python AST) │ │ (JSON/Configs│ │ (.pkl/.pt) │ │ (175+ Rules) │
|
|
112
|
+
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘
|
|
113
|
+
│ │ │ │
|
|
114
|
+
└──────────────────┴──────────────┬─────┴──────────────────┘
|
|
115
|
+
▼
|
|
116
|
+
[AI Feature & Component Profiler]
|
|
117
|
+
▼
|
|
118
|
+
[AISVS Requirements Verification Engine]
|
|
119
|
+
(Evaluates L1/L2/L3: PASS, FAIL, GAP, MANUAL, N/A)
|
|
120
|
+
▼
|
|
121
|
+
┌──────────────────┬──────────────┼──────────────────┬─────────────┐
|
|
122
|
+
▼ ▼ ▼ ▼ ▼
|
|
123
|
+
Terminal Output SARIF 2.1.0 HTML Report Markdown GRC CSV
|
|
124
|
+
(Developer UX) (GitHub Security) (Dynamic Dashboard) (PR Summary) (Auditor)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 1. Python AST Taint Tracking Engine (`analyzers/taint.py`)
|
|
128
|
+
Traces untrusted AI outputs and tool parameters through the Abstract Syntax Tree into critical sinks without relying on heuristic string matching:
|
|
129
|
+
- **Taint Sources**: Return values of LLM completion methods (`client.chat.completions.create`, `messages.create`, `generate_content`, `litellm`, etc.) and arguments passed into functions decorated as tools (`@tool`, `@function_tool`, `@mcp.tool`).
|
|
130
|
+
- **Execution Sinks**:
|
|
131
|
+
- Host Command & Code Execution (`eval`, `exec`, `os.system`, `subprocess.run`, `pty.spawn`, `asyncio.create_subprocess_shell`).
|
|
132
|
+
- SQL Execution (`cursor.execute`, `pd.read_sql`).
|
|
133
|
+
- File System Write/Delete Operations (`Path.write_text`, `os.remove`, `shutil.rmtree`).
|
|
134
|
+
- Arbitrary Outbound Network Requests (`requests.get`, `httpx.post`, `aiohttp`).
|
|
135
|
+
- Unsanitized HTML Rendering (XSS/SSRF via `render_template_string`, `Markup`).
|
|
136
|
+
- **Unbounded Agent Loop Detection**: Detects `while True` agent reasoning loops lacking loop budgets, recursion depth limits, or break conditions.
|
|
137
|
+
|
|
138
|
+
### 2. MCP Security & Governance Engine (`analyzers/mcp_config.py`)
|
|
139
|
+
Inspects MCP server manifests, `mcp.json`, `claude_desktop_config.json`, `.cursor/mcp.json`, and client configurations:
|
|
140
|
+
- **Unpinned Tool Runners**: Flags executions of unpinned packages (`npx -y @package@latest`, `uvx tool`, `docker run image:latest`) vulnerable to supply chain hijacking.
|
|
141
|
+
- **Insecure Transport**: Detects remote MCP servers communicating over unencrypted plaintext HTTP (`http://`).
|
|
142
|
+
- **Secret Leaks**: Discovers hard-coded API keys, bearer tokens, and credentials in MCP environment blocks and headers.
|
|
143
|
+
- **Permission Over-scoping**: Catches servers configured with broad filesystem access (`/`, `~`, `$HOME`).
|
|
144
|
+
- **Human Approval Bypasses**: Flags auto-approval configurations (`autoApprove: ["*"]` or `trust: true`) that bypass human oversight on privileged actions.
|
|
145
|
+
|
|
146
|
+
### 3. Model Weight & Serialization Inspector (`analyzers/artifact.py`)
|
|
147
|
+
Inspects binary model files (`.pkl`, `.pt`, `.pth`, `.bin`, `.joblib`, `.ckpt`):
|
|
148
|
+
- **Executable Format Detection**: Flags pickle-based formats that allow arbitrary Python code execution during deserialization (recommending memory-mapped formats like Safetensors or GGUF).
|
|
149
|
+
- **Opcode Disassembly**: Safely parses the pickle bytecode stream without loading arbitrary objects to detect dangerous globals (`os.system`, `subprocess.Popen`, `posix_spawn`, `eval`, `builtins.exec`).
|
|
150
|
+
|
|
151
|
+
### 4. Declarative Pattern & Call Engine (`rules/`)
|
|
152
|
+
Over 175 rules covering prompt injection, token length enforcement, system message isolation, rate limits, structured JSON schema validation, and GenAI telemetry.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 12 AISVS Chapters: Standard Coverage
|
|
157
|
+
|
|
158
|
+
`aisvs-scan` audits against all **12 Chapters (214 requirements)** defined in the official OWASP standard across verification levels **L1, L2, and L3**:
|
|
159
|
+
|
|
160
|
+
| Chapter | Title | Focus Areas & Controls Checked |
|
|
161
|
+
| :---: | :--- | :--- |
|
|
162
|
+
| **C1** | **Training Data Integrity & Traceability** | Feature minimization (1.1.1), data provenance inventory (1.1.2), dataset integrity monitoring (1.1.4), annotation access controls (1.2.1), data poisoning defenses (1.3.1), bias evaluation (1.3.3), and content sanitization before training (1.3.4). |
|
|
163
|
+
| **C2** | **Input Validation & Prompt Injection** | Input normalization (2.1.1), encoding smuggling defenses (2.1.2), prompt injection classifiers (2.1.3), input length enforcement (2.1.4), character set allow-listing (2.1.5), instruction hierarchy enforcement (2.1.6), and special-token injection prevention (2.1.7). |
|
|
164
|
+
| **C3** | **Model Lifecycle Management** | Model registries (3.1.1), cryptographic artifact signing (3.1.2) and admission verification (3.1.3), safety evaluation test suites (3.2.1), post-quantization validation (3.2.2), pinned model versions (3.2.3), and automated rollback triggers (3.3.1). |
|
|
165
|
+
| **C4** | **Infrastructure & Sandboxing** | Isolated workload execution (4.1.1), safe deserialization format allow-lists (4.1.2), hardware/workload attestation (4.1.3), confidential inference (4.1.4), GPU memory isolation (4.2.4), and on-device secure enclaves (4.3.4). |
|
|
166
|
+
| **C5** | **Access Control & Identity** | Step-up auth for high-risk actions (5.1.1), short-lived agent tokens (5.1.2), endpoint access controls & CORS (5.2.1), retrieval authorization context propagation (5.2.2), post-inference filtering (5.2.4), and multi-tenant compute isolation (5.3.1). |
|
|
167
|
+
| **C6** | **Supply Chain & AI BOM** | Malicious model scanning (6.1.1), approved weight sources (6.1.2), artifact integrity digests (6.1.3), machine-readable AI BOM (CycloneDX/SPDX3) (6.2.1), signed AI BOMs (6.2.2), and dependency confusion protections (6.1.2). |
|
|
168
|
+
| **C7** | **Model Behavior & Output Safety** | Strict schema validation on outputs (7.1.1), length bounds and stop tokens (7.1.2), refusal handling before action (7.1.3), confidence estimation (7.2.1), prompt disclosure filtering (7.3.2), outbound request blocks (7.3.3), and RAG citation provenance (7.4.2). |
|
|
169
|
+
| **C8** | **Memory, Embeddings & Vector DB** | Cross-tenant namespace isolation (8.1.1), retrieval scope constraints (8.1.3), PII masking before embedding (8.2.1), vector anomaly quarantine (8.2.2), memory TTL & expiry (8.3.1), and memory revocation/reset mechanisms (8.3.2). |
|
|
170
|
+
| **C9** | **Orchestration & Agentic Action** | Per-tool quotas & timeouts (9.1.1), execution loop budgets (9.1.2), swarm kill-switches (9.1.3), human approval gates for high-impact actions (9.2.1), reversibility classification (9.2.3), tool sandbox isolation (9.3.1), tool manifests (9.3.3), and agent identity (9.4.1). |
|
|
171
|
+
| **C10** | **Model Context Protocol (MCP)** | Component source verification (10.1.1), local sandbox confinement (10.1.3), token claim validation (10.2.2), no token passthrough (10.2.7), streamable HTTPS transport (10.3.1), DNS rebinding defenses (10.3.3), schema bounds (10.4.13), and tool definition pinning (10.4.8). |
|
|
172
|
+
| **C11** | **Adversarial Robustness** | Alignment suites (11.1.2), adversarial red-teaming (11.1.3), rate-limiting sized to extraction threats (11.2.2), membership-inference mitigations (11.2.4), extraction query detection (11.3.1), and decoding parameter constraints (11.3.5). |
|
|
173
|
+
| **C12** | **Monitoring & Logging** | Session telemetry (12.1.1), safety filtering audit logs (12.1.2), structured GenAI telemetry schema (OTel `gen_ai`) (12.1.3), RAG retrieval logging (12.1.4), jailbreak alerting (12.2.1), token attribution (12.2.5), drift detection (12.3.1), and hallucination tracking (12.3.3). |
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Verification Verdicts
|
|
178
|
+
|
|
179
|
+
For every requirement evaluated, the engine produces one of five verdicts:
|
|
180
|
+
|
|
181
|
+
- **`PASS`**: Positive defense control or implementation indicator was statically verified (e.g. schema validator, token length bound, sandbox runner, signature verification).
|
|
182
|
+
- **`FAIL`**: Actionable security weakness or policy violation detected in code, prompt, configuration, or model artifact.
|
|
183
|
+
- **`GAP`**: Statically verifiable requirement that is applicable to the target but has no detected defense indicator.
|
|
184
|
+
- **`MANUAL`**: The requirement requires human, operational, legal, or physical review (e.g. legal data agreements, out-of-band reviews).
|
|
185
|
+
- **`N/A`**: The relevant AI component (e.g. MCP, RAG, Agent, Training, Edge) was not detected in the target project, eliminating irrelevant noise.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Quickstart
|
|
190
|
+
|
|
191
|
+
### 1. Run Directly (No Installation Needed)
|
|
192
|
+
```bash
|
|
193
|
+
# Clone the scanner
|
|
194
|
+
git clone https://github.com/mesutgungor/aisvs_scanner.git
|
|
195
|
+
cd aisvs_scanner
|
|
196
|
+
|
|
197
|
+
# Run scan on any target
|
|
198
|
+
./bin/aisvs-scan scan /path/to/ai-project
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### 2. Install as a CLI Tool
|
|
202
|
+
```bash
|
|
203
|
+
python3 -m pip install -e .
|
|
204
|
+
aisvs-scan --help
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## CLI Reference
|
|
210
|
+
|
|
211
|
+
### `aisvs-scan scan [TARGET] [OPTIONS]`
|
|
212
|
+
Performs a security verification audit of a target directory, file, or repository.
|
|
213
|
+
|
|
214
|
+
| Flag | Type | Default | Description |
|
|
215
|
+
| :--- | :---: | :---: | :--- |
|
|
216
|
+
| `target` | Positional | `.` | Directory or file to scan. |
|
|
217
|
+
| `-l`, `--level` | `1 \| 2 \| 3` | `3` | Maximum AISVS assurance level to audit against. |
|
|
218
|
+
| `-f`, `--format` | Choice | `terminal` | Report format: `terminal`, `html`, `sarif`, `json`, `markdown`, `csv`. |
|
|
219
|
+
| `-o`, `--output` | Path | `stdout` | Write output to a file instead of standard output. |
|
|
220
|
+
| `--fail-on` | Severity | None | Exit with code `1` if findings at or above this severity are found (`info`, `low`, `medium`, `high`, `critical`). |
|
|
221
|
+
| `-e`, `--exclude` | Glob | None | Exclude paths matching glob pattern (can be specified multiple times). |
|
|
222
|
+
| `--min-severity` | Severity | `low` | Filter out findings below this severity threshold. |
|
|
223
|
+
| `--min-confidence` | Choice | `low` | Filter out findings below confidence level (`low`, `medium`, `high`). |
|
|
224
|
+
| `--standard-version` | Choice | `1.01` | AISVS catalog version (`1.01` or `1.02-dev`). |
|
|
225
|
+
| `--rule` | Rule ID | None | Run only specific rule IDs (can be repeated). |
|
|
226
|
+
| `--ignore-rule` | Rule ID | None | Ignore specific rule IDs (can be repeated). |
|
|
227
|
+
|
|
228
|
+
### `aisvs-scan list-requirements [OPTIONS]`
|
|
229
|
+
Browse the official AISVS requirements catalog.
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# View all requirements for Chapter 10 (MCP Security)
|
|
233
|
+
aisvs-scan list-requirements -c C10
|
|
234
|
+
|
|
235
|
+
# View only foundational Level 1 requirements for Input Validation
|
|
236
|
+
aisvs-scan list-requirements -c C2 -l 1
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### `aisvs-scan list-rules`
|
|
240
|
+
List all 175+ built-in detection rules and defense indicators, showing their mapped AISVS controls and severities.
|
|
241
|
+
|
|
242
|
+
### `aisvs-scan sync`
|
|
243
|
+
Fetch the latest AISVS requirements and descriptions directly from the official [OWASP/AISVS](https://github.com/OWASP/AISVS) repository:
|
|
244
|
+
```bash
|
|
245
|
+
aisvs-scan sync --standard-version 1.02-dev --ref main
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Interactive HTML Dashboard
|
|
251
|
+
|
|
252
|
+
`aisvs-scan` includes a standalone, zero-dependency interactive HTML dashboard (`-f html`):
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
aisvs-scan scan /path/to/project -f html -o aisvs-audit-report.html
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Dashboard Features:
|
|
259
|
+
- **Interactive KPI Status Cards**: Click `PASS`, `FAIL`, `GAP`, `MANUAL`, or `N/A` cards to immediately filter the requirements matrix.
|
|
260
|
+
- **Findings Live Search & Severity Filter**: Instant real-time filtering across Rule IDs, file paths, snippets, and severities.
|
|
261
|
+
- **Chapter Selectors & Quick Pills**: Toggle presets like `Critical & High`, `MCP Only (C10)`, or `Agents (C9)`.
|
|
262
|
+
- **Expandable Code Inspection Drawers**: Click any finding row to reveal the extracted source code snippet, confidence score, and remediation steps.
|
|
263
|
+
- **Requirement Verification Matrix**: Live full-text search with dynamic counter (`Showing X of 214 requirements`).
|
|
264
|
+
- **Global Reset**: Single click to restore all views and filters.
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## Output Formats
|
|
269
|
+
|
|
270
|
+
| Format Flag | Output Type | Primary Use Case |
|
|
271
|
+
| :--- | :--- | :--- |
|
|
272
|
+
| `-f terminal` | Rich ANSI terminal | Interactive developer workflow and local scanning. |
|
|
273
|
+
| `-f html` | Standalone HTML | Executive audit presentations, stakeholder reviews, and security teams. |
|
|
274
|
+
| `-f sarif` | OASIS SARIF 2.1.0 | Native GitHub Code Scanning, GitLab SAST, and IDE problem matchers. |
|
|
275
|
+
| `-f markdown` | GitHub Flavored Markdown | Pull request comments, automated security summaries, and wikis. |
|
|
276
|
+
| `-f json` | Structured JSON | Automation pipelines, SIEM ingest, and security data lakes. |
|
|
277
|
+
| `-f csv` | Comma-Separated Values | Compliance matrices, GRC tracking, and Excel spreadsheets. |
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## CI/CD Integration
|
|
282
|
+
|
|
283
|
+
### GitHub Actions Workflow (with SARIF Alerts & Build Failure)
|
|
284
|
+
|
|
285
|
+
Create `.github/workflows/aisvs-security.yml`:
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
name: OWASP AISVS AI Security Verification
|
|
289
|
+
|
|
290
|
+
on:
|
|
291
|
+
push:
|
|
292
|
+
branches: [main]
|
|
293
|
+
pull_request:
|
|
294
|
+
branches: [main]
|
|
295
|
+
|
|
296
|
+
jobs:
|
|
297
|
+
ai-security-audit:
|
|
298
|
+
runs-on: ubuntu-latest
|
|
299
|
+
permissions:
|
|
300
|
+
security-events: write
|
|
301
|
+
contents: read
|
|
302
|
+
|
|
303
|
+
steps:
|
|
304
|
+
- name: Checkout Code
|
|
305
|
+
uses: actions/checkout@v4
|
|
306
|
+
|
|
307
|
+
- name: Set up Python
|
|
308
|
+
uses: actions/setup-python@v5
|
|
309
|
+
with:
|
|
310
|
+
python-version: '3.12'
|
|
311
|
+
|
|
312
|
+
- name: Checkout AISVS Scanner
|
|
313
|
+
uses: actions/checkout@v4
|
|
314
|
+
with:
|
|
315
|
+
repository: 'mesutgungor/aisvs_scanner'
|
|
316
|
+
path: './.aisvs_scanner'
|
|
317
|
+
|
|
318
|
+
- name: Run AISVS Security Verification
|
|
319
|
+
run: |
|
|
320
|
+
python3 ./.aisvs_scanner/bin/aisvs-scan scan . \
|
|
321
|
+
--level 2 \
|
|
322
|
+
--format sarif \
|
|
323
|
+
--output aisvs-results.sarif \
|
|
324
|
+
--fail-on high \
|
|
325
|
+
-e ".aisvs_scanner/*" -e "tests/*"
|
|
326
|
+
|
|
327
|
+
- name: Upload Results to GitHub Code Scanning
|
|
328
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
329
|
+
if: always()
|
|
330
|
+
with:
|
|
331
|
+
sarif_file: aisvs-results.sarif
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Real-World Benchmark Case Study
|
|
337
|
+
|
|
338
|
+
The scanner was benchmarked against [`assafelovic/gpt-researcher`](https://github.com/assafelovic/gpt-researcher) (30,000+ ⭐), a complex open-source autonomous agent framework containing multi-agent loops, vector retrieval, and MCP servers:
|
|
339
|
+
|
|
340
|
+
```text
|
|
341
|
+
=== OWASP AISVS AI Security Verification Standard Scanner ===
|
|
342
|
+
Standard: OWASP AISVS v1.01 (Level 1-2) | Target: gpt-researcher
|
|
343
|
+
Scanned: 708 files in 51.23s
|
|
344
|
+
|
|
345
|
+
Verification Summary:
|
|
346
|
+
PASS: 70 (Verified defense indicators present)
|
|
347
|
+
FAIL: 15 (Actionable security violations detected)
|
|
348
|
+
GAP: 73 (Applicable controls missing static indicators)
|
|
349
|
+
MANUAL: 7 (Human/operational verification required)
|
|
350
|
+
N/A: 2 (Features not present in target)
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Key Real-World Findings Detected:
|
|
354
|
+
1. **Unpinned MCP Tool Execution (`AIS-MCPCFG-001` → AISVS #10.1.1)**:
|
|
355
|
+
`.mcp.json` executed `uvx gpt-researcher` without an exact version pin or digest. A compromised package release would immediately execute arbitrary code upon client launch.
|
|
356
|
+
2. **Unsafe Pickle Deserialization in Browser Scraper (`AIS-DESER-001` → AISVS #4.1.2, #6.1.1)**:
|
|
357
|
+
`gpt_researcher/scraper/browser/browser.py` used `pickle.load()` on browser cookies, allowing remote code execution via poisoned state files.
|
|
358
|
+
3. **Retrieval Queries Without Tenant Filters (`AIS-RAG-002` → AISVS #5.2.2, #8.1.3)**:
|
|
359
|
+
Vector store queries in `backend/chat/chat.py` were invoked without metadata scoping, allowing potential cross-tenant document leakage in multi-user environments.
|
|
360
|
+
4. **Silent Input Truncation (`AIS-PROMPT-003` → AISVS #2.1.4)**:
|
|
361
|
+
Input strings were silently sliced (`context[:max_len]`) instead of rejected, which can strip safety guardrails and developer instructions.
|
|
362
|
+
5. **MCP Server Bound to `0.0.0.0` Without Host Verification (`AIS-MCP-013` → AISVS #10.3.3)**:
|
|
363
|
+
FastAPI MCP server bound to all interfaces without Origin/Host verification middleware, exposing it to local DNS rebinding attacks.
|
|
364
|
+
|
|
365
|
+
*(An interactive HTML report of this benchmark is included in `examples/reports/gpt_researcher_audit_report.html`)*.
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Suppressing Warnings
|
|
370
|
+
|
|
371
|
+
To suppress false positives or document accepted risks, use inline directives on the offending line:
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
# Suppress a specific rule:
|
|
375
|
+
api_key = get_temporary_test_token() # aisvs:ignore AIS-SECRET-001
|
|
376
|
+
|
|
377
|
+
# Suppress all rules on a line:
|
|
378
|
+
result = client.chat.completions.create(...) # noqa
|
|
379
|
+
|
|
380
|
+
# Or use standard security suppression tags:
|
|
381
|
+
raw_input = req.get_data() # nosec
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
## Testing
|
|
387
|
+
|
|
388
|
+
Run the comprehensive unit test suite:
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -v
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
All unit tests execute hermetically in `< 0.05 seconds`.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Contributing
|
|
399
|
+
|
|
400
|
+
Contributions are welcome! Please follow these steps:
|
|
401
|
+
1. Fork the repository.
|
|
402
|
+
2. Create your feature branch (`git checkout -b feature/new-aisvs-rule`).
|
|
403
|
+
3. Commit your changes (`git commit -m 'Add AISVS check for C10.4.8'`).
|
|
404
|
+
4. Ensure all unit tests pass (`python3 -m unittest discover -s tests`).
|
|
405
|
+
5. Open a Pull Request.
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## License
|
|
410
|
+
|
|
411
|
+
Distributed under the **Apache License 2.0**. See [`LICENSE`](LICENSE) for details.
|
|
412
|
+
|
|
413
|
+
Aligned with the **[OWASP Artificial Intelligence Security Verification Standard](https://github.com/OWASP/AISVS)** project.
|