api-gate-keeper 0.1.1__tar.gz → 0.1.2__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.
Files changed (43) hide show
  1. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/PKG-INFO +53 -1
  2. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/README.md +52 -0
  3. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/PKG-INFO +53 -1
  4. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/SOURCES.txt +3 -1
  5. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/bola_matrix.py +25 -0
  6. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/cli.py +74 -3
  7. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/config.py +5 -0
  8. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/pyproject.toml +1 -1
  9. api_gate_keeper-0.1.2/tests/test_bola_matrix_secondary.py +125 -0
  10. api_gate_keeper-0.1.2/tests/test_seed_endpoint_ids.py +58 -0
  11. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/LICENSE +0 -0
  12. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/dependency_links.txt +0 -0
  13. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/entry_points.txt +0 -0
  14. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/requires.txt +0 -0
  15. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/api_gate_keeper.egg-info/top_level.txt +0 -0
  16. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/__init__.py +0 -0
  17. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/auth.py +0 -0
  18. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/__init__.py +0 -0
  19. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/auth_robustness.py +0 -0
  20. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/authz.py +0 -0
  21. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/baseline.py +0 -0
  22. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/contract_conformance.py +0 -0
  23. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/error_leakage_and_debug_surface.py +0 -0
  24. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/file_upload_security.py +0 -0
  25. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/jwt_security.py +0 -0
  26. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/mass_assignment.py +0 -0
  27. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/nosql_injection.py +0 -0
  28. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/owasp.py +0 -0
  29. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/pen_test.py +0 -0
  30. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/privilege_escalation.py +0 -0
  31. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/rate_limit_and_resource_abuse.py +0 -0
  32. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/schema_contract_and_validation.py +0 -0
  33. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/security_misc.py +0 -0
  34. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/soak_profile.py +0 -0
  35. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/sql_injection.py +0 -0
  36. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/ssrf_and_redirects.py +0 -0
  37. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/token_security.py +0 -0
  38. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/categories/workflow_chains.py +0 -0
  39. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/discovery.py +0 -0
  40. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/executor.py +0 -0
  41. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/models.py +0 -0
  42. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/app_test/report.py +0 -0
  43. {api_gate_keeper-0.1.1 → api_gate_keeper-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: api-gate-keeper
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Web app API security test harness
5
5
  Author-email: Dhalisoft <dhalisoftinc@gmail.com>
6
6
  License-Expression: MIT
@@ -213,6 +213,21 @@ auth:
213
213
  type: none
214
214
  ```
215
215
 
216
+ **Second identity (for genuine cross-account BOLA/IDOR)**:
217
+ ```bash
218
+ apptest --base-url https://your-target.example --api-key <account-a-key> \
219
+ --secondary-api-key <account-b-key> --profile standard
220
+ ```
221
+ `bola_matrix`'s other probes (`bola_neighbor_id_enumeration`, `bola_cross_service_id_probe`,
222
+ `bola_uuid_variant_probe`) all reuse the *same* identity that harvested the ID — they check
223
+ whether IDs are guessable, which against random/UUIDv4 IDs (the common case) rarely finds a
224
+ real object to begin with. Setting `--secondary-api-key` (or `APPTEST_SECONDARY_API_KEY`, or
225
+ `secondary_api_key` in `apptest.yaml`) adds `bola_cross_identity_access_check`: it harvests a
226
+ real ID with the primary identity, then requests that *same, known-real* object with the
227
+ secondary identity's token — the actual question BOLA/IDOR is normally about. A second
228
+ account/API key with its own real data is the only extra setup needed; no code change to
229
+ your target is required.
230
+
216
231
  **Browser-copied session headers / cookies**:
217
232
  ```bash
218
233
  apptest \
@@ -226,6 +241,7 @@ Environment variable fallback is supported (precedence: CLI args > env vars > bu
226
241
 
227
242
  - `APPTEST_BASE_URL`
228
243
  - `APPTEST_API_KEY`
244
+ - `APPTEST_SECONDARY_API_KEY`
229
245
  - `APPTEST_USERNAME`
230
246
  - `APPTEST_PASSWORD`
231
247
  - `APPTEST_AUTH_TYPE`
@@ -686,6 +702,25 @@ Required secrets for the simple workflow:
686
702
 
687
703
  Every test category in API Gate Keeper: what it checks, how it works, and why it matters. Each section ends with a **Test Matrix** table listing the exact runtime `test_name` identifiers, trigger/scope, expected secure outcome, and implementation notes.
688
704
 
705
+ #### Known limitation: `--seed-endpoint` and body-schema-driven categories
706
+
707
+ A target with no OpenAPI spec, tested only via `--seed-endpoint`, gives the categories above
708
+ everything they need for path-based checks (as of this version, `--seed-endpoint` detects
709
+ literal UUID/numeric path segments and treats them as path parameters, the same shape an
710
+ OpenAPI-discovered endpoint already has — see the BOLA Matrix section below). It still can't
711
+ give **`mass_assignment`**, **`schema_contract_and_validation`**, **`file_upload_security`**,
712
+ or **`ssrf_and_redirects`** enough to run: those categories need a declared request-body
713
+ schema (property names/types, or "this field is a file upload") that only an OpenAPI spec
714
+ carries — `--seed-endpoint` has no syntax for it yet. Against a target with no spec, those
715
+ four categories will report `skipped` ("No authenticated JSON mutation endpoints discovered",
716
+ etc.) regardless of profile or `--include-unsafe`. **`workflow_chains`** is a partial case:
717
+ it can now *discover* a resource group from seeded endpoints alone (a POST plus a same-prefix
718
+ instance endpoint, e.g. `POST:/items` + `GET:/items/<id>`), but without a body schema its
719
+ synthetic create request is still likely to be rejected by the target's own validation,
720
+ stopping the chain at `workflow_create` ("Create returned &lt;status&gt;; skipping remaining
721
+ chain steps") rather than running the rest of the chain. Point `--openapi-url` at a spec (even a
722
+ dev-only one your target only serves outside production) to get them running.
723
+
689
724
  ### 1. Baseline
690
725
 
691
726
  **Category name:** `baseline`
@@ -1315,11 +1350,27 @@ Object-level authorization probing that uses harvested IDs from real API respons
1315
1350
  - Applies neighbor-ID mutation patterns where applicable
1316
1351
  - Reuses harvested IDs across compatible ID-bearing endpoints
1317
1352
  - Flags suspicious cross-object successful access patterns as potential BOLA/IDOR
1353
+ - With `--secondary-api-key` set, also requests a harvested real object using a *second*
1354
+ identity's token — a direct cross-account IDOR check, not ID-guessing
1318
1355
 
1319
1356
  #### Why we need it
1320
1357
 
1321
1358
  Live object-ID probing provides stronger signal than synthetic path tampering alone and better matches real attacker behavior for horizontal authorization abuse.
1322
1359
 
1360
+ `bola_neighbor_id_enumeration`, `bola_cross_service_id_probe` and `bola_uuid_variant_probe` all
1361
+ reuse the *same* identity that harvested the ID: they test whether an ID is guessable. Against
1362
+ non-sequential IDs (random UUIDv4s, the common case for most modern APIs) a guessed neighbor
1363
+ essentially never exists, so those three mostly confirm enumeration-resistance rather than
1364
+ authorization. `bola_cross_identity_access_check` (below) is the one that tests the actual
1365
+ BOLA/IDOR question — "can a different, real identity reach this real object" — by using a
1366
+ second identity's own credentials against an ID known to be real, instead of a guess.
1367
+
1368
+ Targets discovered only via `--seed-endpoint` (no OpenAPI spec) are supported: a literal
1369
+ UUID or run of digits in a seeded path (e.g. `--seed-endpoint GET:/items/<real-id>`) is
1370
+ recognized as a path ID the same way an OpenAPI-declared `{id}` parameter is, so this
1371
+ category (and `workflow_chains`, `privilege_escalation`, `error_leakage_and_debug_surface`,
1372
+ `rate_limit_and_resource_abuse`, which look for the same thing) can discover it as a target.
1373
+
1323
1374
  #### Test Matrix
1324
1375
 
1325
1376
  | Test Name | Trigger/Scope | Expected Secure Outcome | Notes |
@@ -1327,6 +1378,7 @@ Live object-ID probing provides stronger signal than synthetic path tampering al
1327
1378
  | `bola_neighbor_id_enumeration` | ID-bearing GET endpoints with harvested IDs | Adjacent/neighbor IDs are denied/hidden | Enumeration resistance probe |
1328
1379
  | `bola_cross_service_id_probe` | ID-bearing GET endpoints with cross-service IDs | Cross-service object IDs are denied/isolated | Domain-isolation probe |
1329
1380
  | `bola_uuid_variant_probe` | UUID-shaped harvested IDs | UUID variants are denied/hidden | Guessability/authorization probe |
1381
+ | `bola_cross_identity_access_check` | ID-bearing GET endpoints, with `--secondary-api-key` set | A second identity is denied access to the primary identity's real object | Genuine cross-account BOLA/IDOR probe; skipped (no result emitted) when `--secondary-api-key` is unset |
1330
1382
  | `bola_matrix_id_harvest` | Category startup | Real object IDs can be harvested | Skipped when harvest pool is empty |
1331
1383
  | `bola_matrix_target_discovery` | Category startup | Suitable GET ID-path targets are discoverable | Skipped when no targets exist |
1332
1384
 
@@ -183,6 +183,21 @@ auth:
183
183
  type: none
184
184
  ```
185
185
 
186
+ **Second identity (for genuine cross-account BOLA/IDOR)**:
187
+ ```bash
188
+ apptest --base-url https://your-target.example --api-key <account-a-key> \
189
+ --secondary-api-key <account-b-key> --profile standard
190
+ ```
191
+ `bola_matrix`'s other probes (`bola_neighbor_id_enumeration`, `bola_cross_service_id_probe`,
192
+ `bola_uuid_variant_probe`) all reuse the *same* identity that harvested the ID — they check
193
+ whether IDs are guessable, which against random/UUIDv4 IDs (the common case) rarely finds a
194
+ real object to begin with. Setting `--secondary-api-key` (or `APPTEST_SECONDARY_API_KEY`, or
195
+ `secondary_api_key` in `apptest.yaml`) adds `bola_cross_identity_access_check`: it harvests a
196
+ real ID with the primary identity, then requests that *same, known-real* object with the
197
+ secondary identity's token — the actual question BOLA/IDOR is normally about. A second
198
+ account/API key with its own real data is the only extra setup needed; no code change to
199
+ your target is required.
200
+
186
201
  **Browser-copied session headers / cookies**:
187
202
  ```bash
188
203
  apptest \
@@ -196,6 +211,7 @@ Environment variable fallback is supported (precedence: CLI args > env vars > bu
196
211
 
197
212
  - `APPTEST_BASE_URL`
198
213
  - `APPTEST_API_KEY`
214
+ - `APPTEST_SECONDARY_API_KEY`
199
215
  - `APPTEST_USERNAME`
200
216
  - `APPTEST_PASSWORD`
201
217
  - `APPTEST_AUTH_TYPE`
@@ -656,6 +672,25 @@ Required secrets for the simple workflow:
656
672
 
657
673
  Every test category in API Gate Keeper: what it checks, how it works, and why it matters. Each section ends with a **Test Matrix** table listing the exact runtime `test_name` identifiers, trigger/scope, expected secure outcome, and implementation notes.
658
674
 
675
+ #### Known limitation: `--seed-endpoint` and body-schema-driven categories
676
+
677
+ A target with no OpenAPI spec, tested only via `--seed-endpoint`, gives the categories above
678
+ everything they need for path-based checks (as of this version, `--seed-endpoint` detects
679
+ literal UUID/numeric path segments and treats them as path parameters, the same shape an
680
+ OpenAPI-discovered endpoint already has — see the BOLA Matrix section below). It still can't
681
+ give **`mass_assignment`**, **`schema_contract_and_validation`**, **`file_upload_security`**,
682
+ or **`ssrf_and_redirects`** enough to run: those categories need a declared request-body
683
+ schema (property names/types, or "this field is a file upload") that only an OpenAPI spec
684
+ carries — `--seed-endpoint` has no syntax for it yet. Against a target with no spec, those
685
+ four categories will report `skipped` ("No authenticated JSON mutation endpoints discovered",
686
+ etc.) regardless of profile or `--include-unsafe`. **`workflow_chains`** is a partial case:
687
+ it can now *discover* a resource group from seeded endpoints alone (a POST plus a same-prefix
688
+ instance endpoint, e.g. `POST:/items` + `GET:/items/<id>`), but without a body schema its
689
+ synthetic create request is still likely to be rejected by the target's own validation,
690
+ stopping the chain at `workflow_create` ("Create returned &lt;status&gt;; skipping remaining
691
+ chain steps") rather than running the rest of the chain. Point `--openapi-url` at a spec (even a
692
+ dev-only one your target only serves outside production) to get them running.
693
+
659
694
  ### 1. Baseline
660
695
 
661
696
  **Category name:** `baseline`
@@ -1285,11 +1320,27 @@ Object-level authorization probing that uses harvested IDs from real API respons
1285
1320
  - Applies neighbor-ID mutation patterns where applicable
1286
1321
  - Reuses harvested IDs across compatible ID-bearing endpoints
1287
1322
  - Flags suspicious cross-object successful access patterns as potential BOLA/IDOR
1323
+ - With `--secondary-api-key` set, also requests a harvested real object using a *second*
1324
+ identity's token — a direct cross-account IDOR check, not ID-guessing
1288
1325
 
1289
1326
  #### Why we need it
1290
1327
 
1291
1328
  Live object-ID probing provides stronger signal than synthetic path tampering alone and better matches real attacker behavior for horizontal authorization abuse.
1292
1329
 
1330
+ `bola_neighbor_id_enumeration`, `bola_cross_service_id_probe` and `bola_uuid_variant_probe` all
1331
+ reuse the *same* identity that harvested the ID: they test whether an ID is guessable. Against
1332
+ non-sequential IDs (random UUIDv4s, the common case for most modern APIs) a guessed neighbor
1333
+ essentially never exists, so those three mostly confirm enumeration-resistance rather than
1334
+ authorization. `bola_cross_identity_access_check` (below) is the one that tests the actual
1335
+ BOLA/IDOR question — "can a different, real identity reach this real object" — by using a
1336
+ second identity's own credentials against an ID known to be real, instead of a guess.
1337
+
1338
+ Targets discovered only via `--seed-endpoint` (no OpenAPI spec) are supported: a literal
1339
+ UUID or run of digits in a seeded path (e.g. `--seed-endpoint GET:/items/<real-id>`) is
1340
+ recognized as a path ID the same way an OpenAPI-declared `{id}` parameter is, so this
1341
+ category (and `workflow_chains`, `privilege_escalation`, `error_leakage_and_debug_surface`,
1342
+ `rate_limit_and_resource_abuse`, which look for the same thing) can discover it as a target.
1343
+
1293
1344
  #### Test Matrix
1294
1345
 
1295
1346
  | Test Name | Trigger/Scope | Expected Secure Outcome | Notes |
@@ -1297,6 +1348,7 @@ Live object-ID probing provides stronger signal than synthetic path tampering al
1297
1348
  | `bola_neighbor_id_enumeration` | ID-bearing GET endpoints with harvested IDs | Adjacent/neighbor IDs are denied/hidden | Enumeration resistance probe |
1298
1349
  | `bola_cross_service_id_probe` | ID-bearing GET endpoints with cross-service IDs | Cross-service object IDs are denied/isolated | Domain-isolation probe |
1299
1350
  | `bola_uuid_variant_probe` | UUID-shaped harvested IDs | UUID variants are denied/hidden | Guessability/authorization probe |
1351
+ | `bola_cross_identity_access_check` | ID-bearing GET endpoints, with `--secondary-api-key` set | A second identity is denied access to the primary identity's real object | Genuine cross-account BOLA/IDOR probe; skipped (no result emitted) when `--secondary-api-key` is unset |
1300
1352
  | `bola_matrix_id_harvest` | Category startup | Real object IDs can be harvested | Skipped when harvest pool is empty |
1301
1353
  | `bola_matrix_target_discovery` | Category startup | Suitable GET ID-path targets are discoverable | Skipped when no targets exist |
1302
1354
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: api-gate-keeper
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Web app API security test harness
5
5
  Author-email: Dhalisoft <dhalisoftinc@gmail.com>
6
6
  License-Expression: MIT
@@ -213,6 +213,21 @@ auth:
213
213
  type: none
214
214
  ```
215
215
 
216
+ **Second identity (for genuine cross-account BOLA/IDOR)**:
217
+ ```bash
218
+ apptest --base-url https://your-target.example --api-key <account-a-key> \
219
+ --secondary-api-key <account-b-key> --profile standard
220
+ ```
221
+ `bola_matrix`'s other probes (`bola_neighbor_id_enumeration`, `bola_cross_service_id_probe`,
222
+ `bola_uuid_variant_probe`) all reuse the *same* identity that harvested the ID — they check
223
+ whether IDs are guessable, which against random/UUIDv4 IDs (the common case) rarely finds a
224
+ real object to begin with. Setting `--secondary-api-key` (or `APPTEST_SECONDARY_API_KEY`, or
225
+ `secondary_api_key` in `apptest.yaml`) adds `bola_cross_identity_access_check`: it harvests a
226
+ real ID with the primary identity, then requests that *same, known-real* object with the
227
+ secondary identity's token — the actual question BOLA/IDOR is normally about. A second
228
+ account/API key with its own real data is the only extra setup needed; no code change to
229
+ your target is required.
230
+
216
231
  **Browser-copied session headers / cookies**:
217
232
  ```bash
218
233
  apptest \
@@ -226,6 +241,7 @@ Environment variable fallback is supported (precedence: CLI args > env vars > bu
226
241
 
227
242
  - `APPTEST_BASE_URL`
228
243
  - `APPTEST_API_KEY`
244
+ - `APPTEST_SECONDARY_API_KEY`
229
245
  - `APPTEST_USERNAME`
230
246
  - `APPTEST_PASSWORD`
231
247
  - `APPTEST_AUTH_TYPE`
@@ -686,6 +702,25 @@ Required secrets for the simple workflow:
686
702
 
687
703
  Every test category in API Gate Keeper: what it checks, how it works, and why it matters. Each section ends with a **Test Matrix** table listing the exact runtime `test_name` identifiers, trigger/scope, expected secure outcome, and implementation notes.
688
704
 
705
+ #### Known limitation: `--seed-endpoint` and body-schema-driven categories
706
+
707
+ A target with no OpenAPI spec, tested only via `--seed-endpoint`, gives the categories above
708
+ everything they need for path-based checks (as of this version, `--seed-endpoint` detects
709
+ literal UUID/numeric path segments and treats them as path parameters, the same shape an
710
+ OpenAPI-discovered endpoint already has — see the BOLA Matrix section below). It still can't
711
+ give **`mass_assignment`**, **`schema_contract_and_validation`**, **`file_upload_security`**,
712
+ or **`ssrf_and_redirects`** enough to run: those categories need a declared request-body
713
+ schema (property names/types, or "this field is a file upload") that only an OpenAPI spec
714
+ carries — `--seed-endpoint` has no syntax for it yet. Against a target with no spec, those
715
+ four categories will report `skipped` ("No authenticated JSON mutation endpoints discovered",
716
+ etc.) regardless of profile or `--include-unsafe`. **`workflow_chains`** is a partial case:
717
+ it can now *discover* a resource group from seeded endpoints alone (a POST plus a same-prefix
718
+ instance endpoint, e.g. `POST:/items` + `GET:/items/<id>`), but without a body schema its
719
+ synthetic create request is still likely to be rejected by the target's own validation,
720
+ stopping the chain at `workflow_create` ("Create returned &lt;status&gt;; skipping remaining
721
+ chain steps") rather than running the rest of the chain. Point `--openapi-url` at a spec (even a
722
+ dev-only one your target only serves outside production) to get them running.
723
+
689
724
  ### 1. Baseline
690
725
 
691
726
  **Category name:** `baseline`
@@ -1315,11 +1350,27 @@ Object-level authorization probing that uses harvested IDs from real API respons
1315
1350
  - Applies neighbor-ID mutation patterns where applicable
1316
1351
  - Reuses harvested IDs across compatible ID-bearing endpoints
1317
1352
  - Flags suspicious cross-object successful access patterns as potential BOLA/IDOR
1353
+ - With `--secondary-api-key` set, also requests a harvested real object using a *second*
1354
+ identity's token — a direct cross-account IDOR check, not ID-guessing
1318
1355
 
1319
1356
  #### Why we need it
1320
1357
 
1321
1358
  Live object-ID probing provides stronger signal than synthetic path tampering alone and better matches real attacker behavior for horizontal authorization abuse.
1322
1359
 
1360
+ `bola_neighbor_id_enumeration`, `bola_cross_service_id_probe` and `bola_uuid_variant_probe` all
1361
+ reuse the *same* identity that harvested the ID: they test whether an ID is guessable. Against
1362
+ non-sequential IDs (random UUIDv4s, the common case for most modern APIs) a guessed neighbor
1363
+ essentially never exists, so those three mostly confirm enumeration-resistance rather than
1364
+ authorization. `bola_cross_identity_access_check` (below) is the one that tests the actual
1365
+ BOLA/IDOR question — "can a different, real identity reach this real object" — by using a
1366
+ second identity's own credentials against an ID known to be real, instead of a guess.
1367
+
1368
+ Targets discovered only via `--seed-endpoint` (no OpenAPI spec) are supported: a literal
1369
+ UUID or run of digits in a seeded path (e.g. `--seed-endpoint GET:/items/<real-id>`) is
1370
+ recognized as a path ID the same way an OpenAPI-declared `{id}` parameter is, so this
1371
+ category (and `workflow_chains`, `privilege_escalation`, `error_leakage_and_debug_surface`,
1372
+ `rate_limit_and_resource_abuse`, which look for the same thing) can discover it as a target.
1373
+
1323
1374
  #### Test Matrix
1324
1375
 
1325
1376
  | Test Name | Trigger/Scope | Expected Secure Outcome | Notes |
@@ -1327,6 +1378,7 @@ Live object-ID probing provides stronger signal than synthetic path tampering al
1327
1378
  | `bola_neighbor_id_enumeration` | ID-bearing GET endpoints with harvested IDs | Adjacent/neighbor IDs are denied/hidden | Enumeration resistance probe |
1328
1379
  | `bola_cross_service_id_probe` | ID-bearing GET endpoints with cross-service IDs | Cross-service object IDs are denied/isolated | Domain-isolation probe |
1329
1380
  | `bola_uuid_variant_probe` | UUID-shaped harvested IDs | UUID variants are denied/hidden | Guessability/authorization probe |
1381
+ | `bola_cross_identity_access_check` | ID-bearing GET endpoints, with `--secondary-api-key` set | A second identity is denied access to the primary identity's real object | Genuine cross-account BOLA/IDOR probe; skipped (no result emitted) when `--secondary-api-key` is unset |
1330
1382
  | `bola_matrix_id_harvest` | Category startup | Real object IDs can be harvested | Skipped when harvest pool is empty |
1331
1383
  | `bola_matrix_target_discovery` | Category startup | Suitable GET ID-path targets are discoverable | Skipped when no targets exist |
1332
1384
 
@@ -36,4 +36,6 @@ app_test/categories/soak_profile.py
36
36
  app_test/categories/sql_injection.py
37
37
  app_test/categories/ssrf_and_redirects.py
38
38
  app_test/categories/token_security.py
39
- app_test/categories/workflow_chains.py
39
+ app_test/categories/workflow_chains.py
40
+ tests/test_bola_matrix_secondary.py
41
+ tests/test_seed_endpoint_ids.py
@@ -231,6 +231,7 @@ def run(
231
231
  token: str | None,
232
232
  endpoints: list[EndpointSpec],
233
233
  include_unsafe: bool,
234
+ secondary_token: str | None = None,
234
235
  ) -> list[ExecutionResult]:
235
236
  del include_unsafe # bola_matrix is always read-only
236
237
 
@@ -337,4 +338,28 @@ def run(
337
338
  )
338
339
  )
339
340
 
341
+ # --- Probe 4: cross-identity access check (needs --secondary-api-key) ---
342
+ # Probes 1-3 all reuse the *same* token as the one that harvested the
343
+ # ID: they test whether IDs are guessable, not whether a different,
344
+ # real identity is denied a real object. Against random/UUIDv4 IDs
345
+ # (the common case), probes 1 and 3 rarely land on an ID that
346
+ # exists at all, so they mostly confirm non-enumerability rather
347
+ # than authorization. This probe is the one that actually answers
348
+ # "can user B read/act on user A's real object" — the question
349
+ # BOLA/IDOR is normally about — using a harvested ID known to be
350
+ # real, with a token known to belong to someone else.
351
+ if secondary_token and same_service_ids:
352
+ real_id = same_service_ids[0]
353
+ results.append(
354
+ _get_probe(
355
+ client, base_url, endpoint, secondary_token, real_id,
356
+ "bola_cross_identity_access_check",
357
+ (
358
+ f"A second identity accessed a real object ({real_id!r}) it does not "
359
+ f"own — cross-account BOLA/IDOR"
360
+ ),
361
+ f"A second identity could not access object {real_id!r} (correctly isolated)",
362
+ )
363
+ )
364
+
340
365
  return results
@@ -17,7 +17,7 @@ from app_test.auth import login_and_get_token, serialize_bearer_token, serialize
17
17
  from app_test.categories import auth_robustness, authz, baseline, bola_matrix, contract_conformance, error_leakage_and_debug_surface, file_upload_security, jwt_security, mass_assignment, nosql_injection, owasp, pen_test, privilege_escalation, rate_limit_and_resource_abuse, schema_contract_and_validation, security_misc, soak_profile, sql_injection, ssrf_and_redirects, token_security, workflow_chains
18
18
  from app_test.config import AppConfig
19
19
  from app_test.discovery import discover_endpoints
20
- from app_test.models import EndpointSpec
20
+ from app_test.models import EndpointSpec, ParameterSpec
21
21
  from app_test.report import build_summary, write_junit_report, write_reports, write_sarif_report
22
22
 
23
23
 
@@ -96,6 +96,16 @@ def parse_args() -> argparse.Namespace:
96
96
  default=None,
97
97
  help="API key used as Bearer token (or env APPTEST_API_KEY); skips username/password login",
98
98
  )
99
+ parser.add_argument(
100
+ "--secondary-api-key",
101
+ default=None,
102
+ help=(
103
+ "A second account's API key/Bearer token (or env APPTEST_SECONDARY_API_KEY). "
104
+ "When set, bola_matrix also checks whether this identity can access the primary "
105
+ "identity's real objects — genuine cross-account BOLA/IDOR, not just ID-guessing "
106
+ "against random/non-sequential IDs."
107
+ ),
108
+ )
99
109
  parser.add_argument(
100
110
  "--username",
101
111
  default=None,
@@ -351,6 +361,15 @@ PLACEHOLDER_PASSWORD = "your-password"
351
361
  def _build_config(args: argparse.Namespace, config_data: dict[str, object]) -> AppConfig:
352
362
  base_url = _expand_env_vars(_resolve_value(args.base_url, "APPTEST_BASE_URL", config_data, "base_url", PLACEHOLDER_BASE_URL))
353
363
  api_key = _expand_env_vars(_resolve_value(args.api_key, "APPTEST_API_KEY", config_data, "api_key", None))
364
+ secondary_api_key = _expand_env_vars(
365
+ _resolve_value(
366
+ getattr(args, "secondary_api_key", None),
367
+ "APPTEST_SECONDARY_API_KEY",
368
+ config_data,
369
+ "secondary_api_key",
370
+ None,
371
+ )
372
+ )
354
373
  username = _expand_env_vars(_resolve_value(args.username, "APPTEST_USERNAME", config_data, "username", PLACEHOLDER_USERNAME))
355
374
  password = _expand_env_vars(_resolve_value(args.password, "APPTEST_PASSWORD", config_data, "password", PLACEHOLDER_PASSWORD))
356
375
 
@@ -436,6 +455,7 @@ def _build_config(args: argparse.Namespace, config_data: dict[str, object]) -> A
436
455
  username=str(username),
437
456
  password=str(password),
438
457
  api_key=None if api_key in {None, ""} else str(api_key),
458
+ secondary_api_key=None if secondary_api_key in {None, ""} else str(secondary_api_key),
439
459
  timeout_seconds=timeout_seconds,
440
460
  include_unsafe=include_unsafe,
441
461
  output_dir=output_dir,
@@ -534,6 +554,47 @@ def _target_report_prefix(base_url: str) -> str:
534
554
  return re.sub(r"[^a-z0-9._-]+", "-", candidate).strip("-") or "target"
535
555
 
536
556
 
557
+ # Matches an OpenAPI-discovered spec's own ID detection (see
558
+ # app_test/categories/bola_matrix.py's _UUID_RE/_NUMERIC_RE). Kept as a
559
+ # separate copy here, deliberately: this module has no dependency on any
560
+ # single category, and seeded-endpoint parsing shouldn't gain one.
561
+ _SEED_UUID_RE = re.compile(
562
+ r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", re.IGNORECASE
563
+ )
564
+ _SEED_NUMERIC_RE = re.compile(r"^\d{1,20}$")
565
+
566
+
567
+ def _templatize_seeded_path(path: str) -> tuple[str, list[ParameterSpec]]:
568
+ """
569
+ Turn literal ID-shaped segments (a UUID, or a run of digits) in a
570
+ manually seeded path into named {id}-style path parameters, the same
571
+ shape endpoints discovered from an OpenAPI spec already have.
572
+
573
+ Without this, a seeded endpoint like `GET:/items/<real-uuid>` has an
574
+ empty `parameters` list — every category that asks "does this endpoint
575
+ take a path ID?" (bola_matrix, workflow_chains, privilege_escalation,
576
+ error_leakage_and_debug_surface, rate_limit_and_resource_abuse) answers
577
+ "no" and skips it, even though the seeded path plainly has a real ID in
578
+ it. Giving it the same shape those categories already expect is a
579
+ smaller, safer fix than changing each category individually.
580
+ """
581
+ segments = path.split("/")
582
+ parameters: list[ParameterSpec] = []
583
+ id_count = 0
584
+ for i, segment in enumerate(segments):
585
+ if not segment:
586
+ continue
587
+ if _SEED_UUID_RE.match(segment) or _SEED_NUMERIC_RE.match(segment):
588
+ id_count += 1
589
+ # Named "id", "id2", ... — every one of them contains "id", which
590
+ # is enough for bola_matrix._looks_like_id_path's keyword check,
591
+ # the same way a real spec's "{id}"/"{userId}" would be.
592
+ name = "id" if id_count == 1 else f"id{id_count}"
593
+ segments[i] = f"{{{name}}}"
594
+ parameters.append(ParameterSpec(name=name, where="path", required=True))
595
+ return "/".join(segments), parameters
596
+
597
+
537
598
  def _parse_seed_endpoints(raw_values: object) -> list[EndpointSpec]:
538
599
  if raw_values is None:
539
600
  return []
@@ -560,14 +621,16 @@ def _parse_seed_endpoints(raw_values: object) -> list[EndpointSpec]:
560
621
  raise SystemExit(
561
622
  f"Invalid --seed-endpoint[{index}]: path must start with '/', got {path!r}"
562
623
  )
624
+ templated_path, parameters = _templatize_seeded_path(path)
563
625
  endpoints.append(
564
626
  EndpointSpec(
565
627
  service="manual",
566
628
  service_prefix="",
567
- path=path,
629
+ path=templated_path,
568
630
  method=method,
569
- operation_id=f"manual_{method.lower()}_{path.strip('/').replace('/', '_').replace('.', '_') or 'root'}",
631
+ operation_id=f"manual_{method.lower()}_{templated_path.strip('/').replace('/', '_').replace('.', '_').replace('{', '').replace('}', '') or 'root'}",
570
632
  requires_auth=True,
633
+ parameters=parameters,
571
634
  )
572
635
  )
573
636
  return endpoints
@@ -773,6 +836,13 @@ def main() -> int:
773
836
  "already have, or auth.type: bearer/basic in apptest.yaml instead."
774
837
  ) from exc
775
838
 
839
+ # A second identity, for bola_matrix's cross-account check only. Kept
840
+ # to a bearer token (no username/password login flow) to keep this
841
+ # optional path simple; --api-key/login above is unaffected either way.
842
+ secondary_token = (
843
+ serialize_bearer_token(config.secondary_api_key) if config.secondary_api_key else None
844
+ )
845
+
776
846
  discovery_result = discover_endpoints(
777
847
  client=client,
778
848
  base_url=config.base_url,
@@ -982,6 +1052,7 @@ def main() -> int:
982
1052
  token=token,
983
1053
  endpoints=endpoints,
984
1054
  include_unsafe=allow_unsafe_for("bola_matrix"),
1055
+ secondary_token=secondary_token,
985
1056
  )
986
1057
  )
987
1058
  if "workflow_chains" in selected_categories:
@@ -13,6 +13,11 @@ class AppConfig:
13
13
  username: str = "your-user@example.com"
14
14
  password: str = "your-password"
15
15
  api_key: str | None = None
16
+ # A second, distinct identity's bearer token: lets bola_matrix check real
17
+ # cross-account access (identity B against identity A's real objects),
18
+ # not just same-identity ID-guessing. Optional; bola_matrix falls back
19
+ # to its existing single-identity probes when this is unset.
20
+ secondary_api_key: str | None = None
16
21
  timeout_seconds: float = 20.0
17
22
  include_unsafe: bool = False
18
23
  output_dir: str = "reports"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "api-gate-keeper"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "Web app API security test harness"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,125 @@
1
+ """
2
+ Covers app_test.categories.bola_matrix's new secondary-identity probe
3
+ (bola_cross_identity_access_check): given a primary identity's harvested,
4
+ real object ID, a request made with a *different* identity's token should
5
+ be denied (401/403/404) to pass, and a 2xx should fail the check.
6
+
7
+ Uses httpx.MockTransport (part of httpx itself — no new test dependency)
8
+ to stand in for a target server, keyed by which bearer token a request
9
+ carries.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import unittest
15
+
16
+ import httpx
17
+
18
+ from app_test.categories import bola_matrix
19
+ from app_test.models import EndpointSpec, ParameterSpec
20
+
21
+
22
+ PRIMARY = "bearer::primary-token"
23
+ SECONDARY = "bearer::secondary-token"
24
+ REAL_ID = "eacc3ddc-e652-464f-90ed-6301b1973c1a"
25
+
26
+
27
+ def _endpoints() -> list[EndpointSpec]:
28
+ return [
29
+ EndpointSpec(
30
+ service="manual",
31
+ service_prefix="",
32
+ path="/items",
33
+ method="GET",
34
+ operation_id="manual_get_items",
35
+ requires_auth=True,
36
+ ),
37
+ EndpointSpec(
38
+ service="manual",
39
+ service_prefix="",
40
+ path="/items/{id}",
41
+ method="GET",
42
+ operation_id="manual_get_items_id",
43
+ requires_auth=True,
44
+ parameters=[ParameterSpec(name="id", where="path", required=True)],
45
+ ),
46
+ ]
47
+
48
+
49
+ def _make_client(*, enforce_ownership: bool) -> httpx.Client:
50
+ """A stand-in target: `enforce_ownership=True` only accepts the
51
+ primary identity's own token for the item (a correctly isolated
52
+ server); `enforce_ownership=False` accepts any authenticated token at
53
+ all (the vulnerable case bola_cross_identity_access_check exists to
54
+ catch)."""
55
+
56
+ def handler(request: httpx.Request) -> httpx.Response:
57
+ if request.url.path == "/items":
58
+ # Collection endpoint: harvested by whichever token requests it.
59
+ return httpx.Response(200, json={"items": [{"id": REAL_ID}]})
60
+ if request.url.path == f"/items/{REAL_ID}":
61
+ authorized = (
62
+ request.headers.get("Authorization") == "Bearer primary-token"
63
+ if enforce_ownership
64
+ else bool(request.headers.get("Authorization"))
65
+ )
66
+ if authorized:
67
+ return httpx.Response(200, json={"id": REAL_ID, "notes": "private"})
68
+ return httpx.Response(404, json={"message": "Item not found"})
69
+ return httpx.Response(404)
70
+
71
+ return httpx.Client(transport=httpx.MockTransport(handler))
72
+
73
+
74
+ class BolaMatrixSecondaryIdentityTests(unittest.TestCase):
75
+ def test_denied_secondary_identity_passes(self) -> None:
76
+ # Only the primary token's bearer value is ever accepted by the
77
+ # object's owner-check — the secondary identity should be denied.
78
+ client = _make_client(enforce_ownership=True)
79
+ results = bola_matrix.run(
80
+ client=client,
81
+ base_url="https://example.test",
82
+ token=PRIMARY,
83
+ endpoints=_endpoints(),
84
+ include_unsafe=False,
85
+ secondary_token=SECONDARY,
86
+ )
87
+ cross_identity = [r for r in results if r.test_name == "bola_cross_identity_access_check"]
88
+ self.assertEqual(len(cross_identity), 1)
89
+ self.assertEqual(cross_identity[0].status, "pass")
90
+ self.assertEqual(cross_identity[0].http_status, 404)
91
+
92
+ def test_vulnerable_server_fails(self) -> None:
93
+ # A server that accepts anyone's token for anyone's object: the
94
+ # check should fail and say so.
95
+ client = _make_client(enforce_ownership=False)
96
+ results = bola_matrix.run(
97
+ client=client,
98
+ base_url="https://example.test",
99
+ token=PRIMARY,
100
+ endpoints=_endpoints(),
101
+ include_unsafe=False,
102
+ secondary_token=SECONDARY,
103
+ )
104
+ cross_identity = [r for r in results if r.test_name == "bola_cross_identity_access_check"]
105
+ self.assertEqual(len(cross_identity), 1)
106
+ self.assertEqual(cross_identity[0].status, "fail")
107
+ self.assertIn("cross-account BOLA/IDOR", cross_identity[0].message)
108
+
109
+ def test_no_secondary_token_means_no_cross_identity_check(self) -> None:
110
+ # Backward compatible: omitting --secondary-api-key changes nothing
111
+ # about the existing single-identity probes.
112
+ client = _make_client(enforce_ownership=True)
113
+ results = bola_matrix.run(
114
+ client=client,
115
+ base_url="https://example.test",
116
+ token=PRIMARY,
117
+ endpoints=_endpoints(),
118
+ include_unsafe=False,
119
+ )
120
+ cross_identity = [r for r in results if r.test_name == "bola_cross_identity_access_check"]
121
+ self.assertEqual(cross_identity, [])
122
+
123
+
124
+ if __name__ == "__main__":
125
+ unittest.main()
@@ -0,0 +1,58 @@
1
+ """
2
+ Covers app_test.cli._parse_seed_endpoints / _templatize_seeded_path: a
3
+ manually seeded endpoint with a literal UUID or numeric ID in its path
4
+ should come out shaped the same way an OpenAPI-discovered one would (a
5
+ named {id}-style path parameter), so every category that asks "does this
6
+ endpoint take a path ID?" can see it.
7
+
8
+ No new test dependency: plain unittest, run with
9
+ `python -m unittest discover -s tests` from the repo root.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import unittest
15
+
16
+ from app_test.cli import _parse_seed_endpoints
17
+
18
+
19
+ class ParseSeedEndpointsTests(unittest.TestCase):
20
+ def test_uuid_segment_becomes_a_named_path_parameter(self) -> None:
21
+ endpoints = _parse_seed_endpoints(
22
+ ["GET:/items/eacc3ddc-e652-464f-90ed-6301b1973c1a"]
23
+ )
24
+ self.assertEqual(len(endpoints), 1)
25
+ endpoint = endpoints[0]
26
+ self.assertEqual(endpoint.path, "/items/{id}")
27
+ self.assertEqual(len(endpoint.parameters), 1)
28
+ self.assertEqual(endpoint.parameters[0].name, "id")
29
+ self.assertEqual(endpoint.parameters[0].where, "path")
30
+
31
+ def test_numeric_segment_becomes_a_named_path_parameter(self) -> None:
32
+ endpoints = _parse_seed_endpoints(["GET:/users/482910"])
33
+ self.assertEqual(endpoints[0].path, "/users/{id}")
34
+ self.assertEqual(endpoints[0].parameters[0].name, "id")
35
+
36
+ def test_two_id_segments_each_get_a_distinct_name(self) -> None:
37
+ endpoints = _parse_seed_endpoints(
38
+ ["GET:/orgs/11111111-1111-1111-1111-111111111111/items/42"]
39
+ )
40
+ endpoint = endpoints[0]
41
+ self.assertEqual(endpoint.path, "/orgs/{id}/items/{id2}")
42
+ names = [p.name for p in endpoint.parameters]
43
+ self.assertEqual(names, ["id", "id2"])
44
+
45
+ def test_non_id_segments_are_left_alone(self) -> None:
46
+ endpoints = _parse_seed_endpoints(["POST:/items/archive-folder"])
47
+ endpoint = endpoints[0]
48
+ self.assertEqual(endpoint.path, "/items/archive-folder")
49
+ self.assertEqual(endpoint.parameters, [])
50
+
51
+ def test_endpoint_with_no_id_is_unaffected(self) -> None:
52
+ endpoints = _parse_seed_endpoints(["GET:/health"])
53
+ self.assertEqual(endpoints[0].path, "/health")
54
+ self.assertEqual(endpoints[0].parameters, [])
55
+
56
+
57
+ if __name__ == "__main__":
58
+ unittest.main()
File without changes