aiwaf 1.2.3 → 1.2.4
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.
- package/README.md +73 -37
- package/lib/injectionAnalysis.js +1204 -52
- package/lib/routeRisks.js +1 -1
- package/lib/wafMiddleware.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -39,15 +39,15 @@ the supported Redis backends when sharing limits across workers.
|
|
|
39
39
|
|
|
40
40
|
Each package is versioned and released independently.
|
|
41
41
|
|
|
42
|
-
Python 1.2.
|
|
42
|
+
Python 1.2.5, Rust/Python 0.2.12, Node.js 1.2.4, WASM 0.2.9, and Java 1.3.8 are local source targets. See the package table below and [CHANGELOG](CHANGELOG.md) for release changes.
|
|
43
43
|
|
|
44
44
|
| Runtime | Package | Repository version | Primary use |
|
|
45
45
|
| --- | --- | ---: | --- |
|
|
46
|
-
| Python | [`aiwaf`](https://pypi.org/project/aiwaf/) | `1.2.
|
|
47
|
-
| Node.js | [`aiwaf`](https://www.npmjs.com/package/aiwaf) | `1.2.
|
|
46
|
+
| Python | [`aiwaf`](https://pypi.org/project/aiwaf/) | `1.2.5` | Django, Flask, and FastAPI protection |
|
|
47
|
+
| Node.js | [`aiwaf`](https://www.npmjs.com/package/aiwaf) | `1.2.4` | Express and Node framework middleware |
|
|
48
48
|
| Rust/Python | [`aiwaf-rust`](https://pypi.org/project/aiwaf-rust/) | `0.2.12` | Native Python acceleration and JSON model inference |
|
|
49
49
|
| WebAssembly | [`aiwaf-wasm`](https://www.npmjs.com/package/aiwaf-wasm) | `0.2.9` | Rust detection and model primitives for JavaScript |
|
|
50
|
-
| Java | `io.github.aiwaf-project:aiwaf-java` | `1.3.
|
|
50
|
+
| Java | `io.github.aiwaf-project:aiwaf-java` | `1.3.8` | Spring MVC and Jakarta Servlet protection |
|
|
51
51
|
|
|
52
52
|
Supported framework integrations include Django, Flask, FastAPI, Express, Fastify, Hapi, Koa, NestJS, Next.js API routes, AdonisJS, Sails.js, Spring MVC, and Jakarta Servlet.
|
|
53
53
|
|
|
@@ -91,10 +91,9 @@ If untrusted hosts can reach the application directly from your private network,
|
|
|
91
91
|
|
|
92
92
|
## Injection audit
|
|
93
93
|
|
|
94
|
-
`audit` reads your source code and reports where request input can reach
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
requests are handled.
|
|
94
|
+
`audit` reads your source code and reports where request input can reach a dangerous
|
|
95
|
+
operation. It parses files without running them, and it doesn't change how requests are
|
|
96
|
+
handled.
|
|
98
97
|
|
|
99
98
|
```bash
|
|
100
99
|
aiwaf audit path/to/app # Python
|
|
@@ -104,18 +103,57 @@ java -cp <classpath> com.aiwaf.cli.AiwafConsole audit src # Java, needs a JDK
|
|
|
104
103
|
|
|
105
104
|
| Language | Frameworks | Parser |
|
|
106
105
|
| --- | --- | --- |
|
|
107
|
-
| Python | Django, Flask, FastAPI | `ast` |
|
|
108
|
-
| Node.js | Express, Fastify, Hapi, Koa, NestJS, Next.js, AdonisJS, Sails | `@babel/parser` |
|
|
109
|
-
| Java | Spring, Jakarta Servlet, JAX-RS
|
|
106
|
+
| Python | Django, Flask, FastAPI, Graphene, Strawberry, Ariadne, Channels, Flask-SocketIO | `ast` |
|
|
107
|
+
| Node.js | Express, Fastify, Hapi, Koa, NestJS, Next.js (routes and server actions), Remix, tRPC, GraphQL resolvers, AdonisJS, Sails, ws and Socket.IO | `@babel/parser` |
|
|
108
|
+
| Java | Spring MVC and WebFlux, Spring GraphQL, Netflix DGS, Jakarta Servlet, JAX-RS, Spring messaging and Jakarta WebSocket | JDK Compiler Tree API |
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
It reports these operations:
|
|
111
|
+
|
|
112
|
+
| Operation | Examples |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `sql`, `nosql` | `cursor.execute`, `db.query`, `jdbcTemplate.update`, `collection.find` |
|
|
115
|
+
| `command` | `os.system`, `exec`, `Runtime.exec`, `ProcessBuilder` |
|
|
116
|
+
| `path` | `open`, `fs.readFile`, `new File`, `Path.read_text` |
|
|
117
|
+
| `ssrf` | `requests.get`, `fetch`, `RestTemplate` |
|
|
118
|
+
| `code`, `template`, `deserialization` | `eval`, `render_template_string`, `pickle.loads` |
|
|
119
|
+
| `xss` | text returned from a Flask view, `res.send`, `ctx.body`, `response.getWriter()` |
|
|
120
|
+
| `redirect` | `redirect`, `res.redirect`, `sendRedirect` |
|
|
121
|
+
| `ldap`, `xpath` | `conn.search`, `client.search`, `xpath`, `XPath.evaluate` |
|
|
122
|
+
| `xxe` | XML parsers with external entities turned on |
|
|
123
|
+
| `redos` | regular expressions built from input |
|
|
124
|
+
| `prototype` (Node.js) | `obj[key] = value` with a key from input, `_.merge` |
|
|
125
|
+
|
|
126
|
+
It follows input through helpers, return values, other files and classes, objects that
|
|
127
|
+
keep input in fields, middleware that keeps input on the request, and callbacks such as
|
|
128
|
+
`.then()` and `.map()`. It understands checks: `if not name.isalnum(): return`, allowlists,
|
|
129
|
+
regex tests and `'..'` checks make a value safe, and encoders such as `html.escape` make
|
|
130
|
+
it safe only for what they encode for (HTML, not SQL). Values decided before the program
|
|
131
|
+
runs, dict keys and list positions are followed, so `m['safe']` isn't confused with
|
|
132
|
+
`m['input']`.
|
|
133
|
+
|
|
134
|
+
On the [OWASP Benchmark](https://owasp.org/www-project-benchmark/), whose labelled test
|
|
135
|
+
cases are real vulnerabilities or safe look-alikes, the Java audit finds every one of
|
|
136
|
+
1,572 injection cases with no false alarms, and the Python audit every one of 677
|
|
137
|
+
(scores of +100 on OWASP's scale). The benchmarks are small synthetic cases, so this isn't
|
|
138
|
+
proof of the same on real applications; `scripts/audit_benchmark.py` repeats the
|
|
139
|
+
measurement on a checkout of either.
|
|
140
|
+
|
|
141
|
+
All three accept `--format text|json|sarif`, `--output <file>`, `--include-tests`,
|
|
142
|
+
`--fail-on-findings`, `--manifest <file>` and `--baseline <file>`. The exit status is 0
|
|
143
|
+
when the scan completes, 1 with `--fail-on-findings` when something is found, and 2 for a
|
|
144
|
+
bad path or argument.
|
|
145
|
+
|
|
146
|
+
- `--format sarif` writes SARIF 2.1.0, which GitHub code scanning and other tools read.
|
|
147
|
+
- `--baseline report.json` leaves out findings already in an earlier JSON report, so CI
|
|
148
|
+
fails only on new ones. Findings match by file, operation, call, function and input,
|
|
149
|
+
not line, so moved code still matches.
|
|
150
|
+
- A comment `aiwaf: ignore` on a finding's line or the line above leaves it out, and
|
|
151
|
+
`aiwaf: ignore[sql, xss]` leaves out only those operations. The report counts them.
|
|
114
152
|
|
|
115
153
|
A finding is a path worth reading, not a confirmed vulnerability. A reverse proxy, for
|
|
116
154
|
example, will report its upstream request because forwarding input is its job. A clean
|
|
117
|
-
report doesn't prove the code is safe:
|
|
118
|
-
|
|
155
|
+
report doesn't prove the code is safe: reflection, dynamic calls and library code can be
|
|
156
|
+
missed, and helpers are followed three calls deep.
|
|
119
157
|
|
|
120
158
|
Java can also build a route manifest from source, without starting the application.
|
|
121
159
|
This is how plain Servlet applications get a manifest:
|
|
@@ -256,7 +294,7 @@ pip install "aiwaf[django]"
|
|
|
256
294
|
pip install "aiwaf[flask]"
|
|
257
295
|
pip install "aiwaf[fastapi]"
|
|
258
296
|
|
|
259
|
-
# Backward-compatible alias; Python 1.2.
|
|
297
|
+
# Backward-compatible alias; Python 1.2.5 already installs aiwaf-rust
|
|
260
298
|
pip install "aiwaf[rust]"
|
|
261
299
|
|
|
262
300
|
# Node.js middleware
|
|
@@ -266,13 +304,13 @@ npm install aiwaf
|
|
|
266
304
|
npm install aiwaf-wasm
|
|
267
305
|
```
|
|
268
306
|
|
|
269
|
-
Java 1.3.
|
|
307
|
+
Java 1.3.8, after it is published to Maven Central:
|
|
270
308
|
|
|
271
309
|
```xml
|
|
272
310
|
<dependency>
|
|
273
311
|
<groupId>io.github.aiwaf-project</groupId>
|
|
274
312
|
<artifactId>aiwaf-java</artifactId>
|
|
275
|
-
<version>1.3.
|
|
313
|
+
<version>1.3.8</version>
|
|
276
314
|
</dependency>
|
|
277
315
|
```
|
|
278
316
|
|
|
@@ -280,7 +318,7 @@ Java 1.3.7, after it is published to Maven Central:
|
|
|
280
318
|
|
|
281
319
|
The Python package requires Python 3.10 or newer. Framework dependencies are optional, so install only the extra needed by the application.
|
|
282
320
|
|
|
283
|
-
Python 1.2.
|
|
321
|
+
Python 1.2.5 requires `aiwaf-rust>=0.2.12`; the `rust` extra remains an installation
|
|
284
322
|
alias. Publish the matching Rust wheel with `NativeCSVPipeline` support before
|
|
285
323
|
the Python release. The Rust release workflow builds Linux x86_64/aarch64,
|
|
286
324
|
musl x86_64, macOS x86_64/arm64 and Windows x86_64 wheels and checks the native
|
|
@@ -1103,7 +1141,7 @@ existence to `Boolean(req.route)`. Supply accurate facts when the firewall runs
|
|
|
1103
1141
|
before Express resolves routes. Country headers are not implicitly trusted.
|
|
1104
1142
|
|
|
1105
1143
|
**`aiwaf(options)` runs the native pipeline by default** when two things hold: the
|
|
1106
|
-
installed aiwaf-wasm is 0.2.
|
|
1144
|
+
installed aiwaf-wasm is 0.2.9 or newer (it has every native feature), and every option
|
|
1107
1145
|
carries over exactly, so the conversion report below lists no differences. Otherwise it
|
|
1108
1146
|
runs the regular middleware, as before. It logs one line when it picks the native
|
|
1109
1147
|
pipeline. To keep the regular middleware, set `AIWAF_NATIVE_PIPELINE: false` in the
|
|
@@ -1350,7 +1388,7 @@ cp -R ../licenses crates/aiwaf_wasm/pkg/
|
|
|
1350
1388
|
|
|
1351
1389
|
## Java package
|
|
1352
1390
|
|
|
1353
|
-
AIWAF Java 1.3.
|
|
1391
|
+
AIWAF Java 1.3.8 targets Java 17, Spring Framework 7.0, and Jakarta Servlet 6.1. It is a native Java implementation and does not load the Rust library.
|
|
1354
1392
|
|
|
1355
1393
|
### Core engine
|
|
1356
1394
|
|
|
@@ -1439,7 +1477,7 @@ UUID protection uses Python-compatible weighted signals: malformed input, valid
|
|
|
1439
1477
|
Generate a route manifest from the live Spring application rather than supplying controller methods manually:
|
|
1440
1478
|
|
|
1441
1479
|
```bash
|
|
1442
|
-
java -cp "your-app.jar:aiwaf-java-1.3.
|
|
1480
|
+
java -cp "your-app.jar:aiwaf-java-1.3.8.jar" \
|
|
1443
1481
|
com.aiwaf.cli.AiwafConsole init \
|
|
1444
1482
|
--app com.example.Application \
|
|
1445
1483
|
--output .aiwaf/paths.json
|
|
@@ -1635,14 +1673,11 @@ python aiwaf_test.py --python-only
|
|
|
1635
1673
|
python aiwaf_test.py --rust-only
|
|
1636
1674
|
python aiwaf_test.py --js-only
|
|
1637
1675
|
python aiwaf_test.py --wasm-only
|
|
1676
|
+
python aiwaf_test.py --java-only
|
|
1638
1677
|
```
|
|
1639
1678
|
|
|
1640
|
-
Java
|
|
1641
|
-
|
|
1642
|
-
```bash
|
|
1643
|
-
cd java
|
|
1644
|
-
mvn test
|
|
1645
|
-
```
|
|
1679
|
+
Full runs include the Java suite, which needs a JDK 17 or newer and Maven. Use `--no-java`
|
|
1680
|
+
to skip it on a machine without them, or run it directly with `mvn -f java/pom.xml test`.
|
|
1646
1681
|
|
|
1647
1682
|
### Direct package commands
|
|
1648
1683
|
|
|
@@ -1670,11 +1705,11 @@ Release versions and tags must match the relevant manifest.
|
|
|
1670
1705
|
|
|
1671
1706
|
| Package | Manifest | Tag | Workflow |
|
|
1672
1707
|
| --- | --- | --- | --- |
|
|
1673
|
-
| Python `aiwaf` | `pyproject.toml` | `python-v1.2.
|
|
1674
|
-
| npm `aiwaf` | `js/package.json` | `js-v1.2.
|
|
1708
|
+
| Python `aiwaf` | `pyproject.toml` | `python-v1.2.5` | `python-publish.yml` |
|
|
1709
|
+
| npm `aiwaf` | `js/package.json` | `js-v1.2.4` | `npm-publish.yml` |
|
|
1675
1710
|
| PyPI `aiwaf-rust` | `rust/pyproject.toml` + `rust/Cargo.toml` | `rust-v0.2.12` | `rust-publish.yml` |
|
|
1676
1711
|
| npm `aiwaf-wasm` | `rust/crates/aiwaf_wasm/Cargo.toml` | `wasm-v0.2.9` | `wasm-publish.yml` |
|
|
1677
|
-
| Maven `aiwaf-java` | `java/pom.xml` | `java-v1.3.
|
|
1712
|
+
| Maven `aiwaf-java` | `java/pom.xml` | `java-v1.3.8` | `java-publish.yml` |
|
|
1678
1713
|
|
|
1679
1714
|
Python and Rust publish to PyPI with trusted publishing. The npm workflows use npm trusted publishing and stage packages for approval. Configure the trusted publisher with organization `aiwaf-project`, repository `aiwaf`, the exact workflow filename, and the environment used by that workflow.
|
|
1680
1715
|
|
|
@@ -1682,11 +1717,12 @@ Java publishing uses the protected `maven-publish` environment plus `GPG_PRIVATE
|
|
|
1682
1717
|
|
|
1683
1718
|
Registry releases are immutable. Increment the relevant manifest version before publishing another release.
|
|
1684
1719
|
|
|
1685
|
-
This release is Python `aiwaf 1.2.
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
`aiwaf-
|
|
1689
|
-
|
|
1720
|
+
This release is Python `aiwaf 1.2.5`, npm `aiwaf 1.2.4` and Java `aiwaf-java 1.3.8`, with
|
|
1721
|
+
the injection audit changes. Python 1.2.4, Java 1.3.7, `aiwaf-rust 0.2.12` and
|
|
1722
|
+
`aiwaf-wasm 0.2.9` are already published, and the engines are unchanged. Python now requires
|
|
1723
|
+
`aiwaf-rust>=0.2.12` and npm `aiwaf` `aiwaf-wasm ^0.2.9`, so every native feature is available
|
|
1724
|
+
after an install. npm `aiwaf` 1.2.3 was staged but never released, and npm doesn't reuse a
|
|
1725
|
+
version, so npm `aiwaf 1.2.4` also ships the Node.js changes listed under Python 1.2.4.
|
|
1690
1726
|
|
|
1691
1727
|
## Security and limitations
|
|
1692
1728
|
|