kiosk-redteam 0.5.20
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +158 -0
- data/LICENSE.txt +202 -0
- data/README.md +247 -0
- data/lib/kiosk/redteam/battery.rb +148 -0
- data/lib/kiosk/redteam/leak_scan.rb +104 -0
- data/lib/kiosk/redteam/profile.rb +58 -0
- data/lib/kiosk/redteam/runner.rb +37 -0
- data/lib/kiosk/redteam/scenario.rb +34 -0
- data/lib/kiosk/redteam/scenarios/cross_tenant_read.rb +57 -0
- data/lib/kiosk/redteam/scenarios/device_grant_role_self_selection.rb +117 -0
- data/lib/kiosk/redteam/scenarios/expired_kyc.rb +27 -0
- data/lib/kiosk/redteam/scenarios/forged_kyc.rb +27 -0
- data/lib/kiosk/redteam/scenarios/forged_user_id.rb +108 -0
- data/lib/kiosk/redteam/scenarios/kyc_attack.rb +43 -0
- data/lib/kiosk/redteam/scenarios/mandate_principal_swap.rb +32 -0
- data/lib/kiosk/redteam/scenarios/mandate_replay.rb +42 -0
- data/lib/kiosk/redteam/scenarios/missing_kyc.rb +38 -0
- data/lib/kiosk/redteam/scenarios/pay_for_other_use_self.rb +59 -0
- data/lib/kiosk/redteam/scenarios/privilege_self_selection.rb +51 -0
- data/lib/kiosk/redteam/scenarios/registration_without_pow.rb +70 -0
- data/lib/kiosk/redteam/scenarios/spent_resource_reuse.rb +47 -0
- data/lib/kiosk/redteam/scenarios/token_tampering.rb +40 -0
- data/lib/kiosk/redteam/scenarios/unpaid_gated_action.rb +37 -0
- data/lib/kiosk/redteam/scenarios/wrong_currency_cart.rb +39 -0
- data/lib/kiosk/redteam/staging.rb +45 -0
- data/lib/kiosk/redteam/token_claims.rb +51 -0
- data/lib/kiosk/redteam/verdict.rb +13 -0
- data/lib/kiosk/redteam/verdicts.rb +130 -0
- data/lib/kiosk/redteam/version.rb +7 -0
- data/lib/kiosk/redteam.rb +94 -0
- metadata +113 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f685eaaad2b4f5c00e9a30b853c7b955944b5ebfe3cc2232da9595a5deb5325b
|
|
4
|
+
data.tar.gz: 5e7361227cfe0ac60f95085a875af20451992d0ed0a0514ca1ef3d7f50101efa
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c59a347eb3eb6261fd991cb85047c3698bac43d6d29d3dbbfcb1bbcc6cec4a86d1957dbc47a5853cd9be412b55219cfc45ac5821b8ac4d2b4ef659000adf7a54
|
|
7
|
+
data.tar.gz: 043e887db0d72927446207bf3e0c3dff8aee07d44f976890c74c40f72660ee0e4d2f74d6ff12d93f47809884a6c067db5e8b89b044b931b0a4e05fbe0d030625
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes follow [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
How to write an entry, and what a release section means: `CHANGELOG-RULE.md` at
|
|
6
|
+
the root of this repository —
|
|
7
|
+
<https://github.com/kiosk-hq/kiosk/blob/main/CHANGELOG-RULE.md>. In short: under
|
|
8
|
+
200 characters, one or two sentences, the essence rather than the content; write it
|
|
9
|
+
under `## [Unreleased]`; a cut renames that heading to
|
|
10
|
+
`## [MAJOR.MINOR.PATCH] — <date>` and opens a fresh empty one above it; nothing
|
|
11
|
+
already written is edited.
|
|
12
|
+
|
|
13
|
+
## [Unreleased]
|
|
14
|
+
|
|
15
|
+
## [0.5.20] — 2026-10-20
|
|
16
|
+
|
|
17
|
+
- 2026-10-20: Version 0.5.20, the tree cut that matches skill 0.5.20.
|
|
18
|
+
|
|
19
|
+
## [0.5.19] — 2026-10-20
|
|
20
|
+
|
|
21
|
+
- 2026-10-20: Version 0.5.19, the tree cut that matches skill 0.5.19.
|
|
22
|
+
|
|
23
|
+
## [0.5.18] — 2026-10-18
|
|
24
|
+
|
|
25
|
+
- 2026-10-18: Version 0.5.18, the tree cut that matches skill 0.5.18.
|
|
26
|
+
|
|
27
|
+
## [0.5.17] — 2026-10-18
|
|
28
|
+
|
|
29
|
+
- 2026-10-18: A failed setup step, or a 402 the origin answers before it reads the attack, is UNTESTED: the battery fails, with no BREACH. The JSON line lists `untested`.
|
|
30
|
+
- 2026-10-18: `Battery#record` takes `untested:` for a hand-written beat whose setup step failed. The skooti battery finishes without a stripe-mock.
|
|
31
|
+
|
|
32
|
+
## [0.5.16] — 2026-10-18
|
|
33
|
+
|
|
34
|
+
- 2026-10-18: `Kiosk::Redteam::Scenario.new` takes only `name:`; `category` and `description` are removed.
|
|
35
|
+
- 2026-10-18: `Kiosk::Redteam::Runner#all_blocked?`, `#breaches` and `#blocked` are removed; `Battery#report!` is the exit status.
|
|
36
|
+
- 2026-10-18: kiosk-redteam reads a query answer only as a bare array; ForgedUserId scores BREACH when the owner's query answers no rows array.
|
|
37
|
+
## [0.5.15] — 2026-10-18
|
|
38
|
+
|
|
39
|
+
- 2026-10-18: Version 0.5.15, the tree cut that matches skill 0.5.15.
|
|
40
|
+
|
|
41
|
+
## [0.5.14] — 2026-10-18
|
|
42
|
+
|
|
43
|
+
- 2026-10-18: Version 0.5.14, the tree cut that matches skill 0.5.14.
|
|
44
|
+
|
|
45
|
+
- 2026-10-17: `Battery#skip`, `Battery#entries` and the `echo:` keyword of `Battery#absorb` are removed; nothing used them.
|
|
46
|
+
|
|
47
|
+
## [0.5.13] — 2026-10-11
|
|
48
|
+
|
|
49
|
+
- 2026-10-11: Version 0.5.13, the tree cut that matches skill 0.5.13.
|
|
50
|
+
|
|
51
|
+
- 2026-10-09: **The assistant client, wire, event stream and stripe-mock front move to kiosk-test-support**, which this gem now attacks through.
|
|
52
|
+
|
|
53
|
+
## [0.5.12] — 2026-10-08
|
|
54
|
+
|
|
55
|
+
- 2026-10-08: Version 0.5.12, the tree cut that matches skill 0.5.12; this gem's surface is unchanged.
|
|
56
|
+
|
|
57
|
+
## [0.5.11] — 2026-10-08
|
|
58
|
+
|
|
59
|
+
- 2026-10-08: Version 0.5.11, the tree cut that matches skill 0.5.11; this gem's surface is unchanged.
|
|
60
|
+
|
|
61
|
+
## [0.5.10] — 2026-10-08
|
|
62
|
+
|
|
63
|
+
- 2026-10-08: Version 0.5.10, the tree cut that matches skill 0.5.10 and carries the entries below.
|
|
64
|
+
|
|
65
|
+
- 2026-10-08: The `StripeMock` front relays a long stripe-mock answer intact, so a Checkout Session for card setup reaches the caller.
|
|
66
|
+
- 2026-10-08: `StripeMock.start` fronts stripe-mock so a confirmed charge answers `succeeded` with its whole amount, as Stripe does for a test card.
|
|
67
|
+
- 2026-10-08: `StripeMock.start` brings up a local stripe-mock for a demo suite that pays and refunds with no Stripe key.
|
|
68
|
+
|
|
69
|
+
## [0.5.9] — 2026-10-08
|
|
70
|
+
|
|
71
|
+
- 2026-10-08: Version 0.5.9, the tree cut that matches skill 0.5.9; this gem's surface is unchanged.
|
|
72
|
+
|
|
73
|
+
## [0.5.8] — 2026-10-07
|
|
74
|
+
|
|
75
|
+
- 2026-10-07: Version 0.5.8, the tree cut that matches skill 0.5.8; this gem's surface is unchanged.
|
|
76
|
+
|
|
77
|
+
## [0.5.7] — 2026-10-07
|
|
78
|
+
|
|
79
|
+
- 2026-10-07: Version 0.5.7, the tree cut that matches skill 0.5.7; this gem's surface is unchanged.
|
|
80
|
+
|
|
81
|
+
## [0.5.6] — 2026-10-07
|
|
82
|
+
|
|
83
|
+
- 2026-10-07: **`EventStream.payload_errors`** holds delivered events to the `payload_schema` an origin serves for their topic.
|
|
84
|
+
|
|
85
|
+
## [0.5.5] — 2026-10-07
|
|
86
|
+
|
|
87
|
+
- 2026-10-07: Version 0.5.5, the tree cut that matches skill 0.5.5; this gem's surface is unchanged.
|
|
88
|
+
|
|
89
|
+
## [0.5.4] — 2026-10-07
|
|
90
|
+
|
|
91
|
+
- 2026-10-07: Version 0.5.4, the tree cut that matches skill 0.5.4; this gem's surface is unchanged.
|
|
92
|
+
|
|
93
|
+
## [0.5.3] — 2026-10-06
|
|
94
|
+
|
|
95
|
+
- 2026-10-06: Version 0.5.3, the tree cut that matches skill 0.5.3; this gem's surface is unchanged.
|
|
96
|
+
|
|
97
|
+
## [0.5.2] — 2026-10-06
|
|
98
|
+
|
|
99
|
+
- 2026-10-05: **`EventStream`**: the assistant's side of `<endpoint>/events`, to subscribe and wait for an event or assert none arrived.
|
|
100
|
+
|
|
101
|
+
## [0.5.0] — 2026-09-26
|
|
102
|
+
|
|
103
|
+
### Added
|
|
104
|
+
|
|
105
|
+
- **`Profile#gated_action_consumes` — whether the gated action SPENDS the resource.** A verb that only reads back the operator's own decision is right to answer twice, so C3 skips there.
|
|
106
|
+
|
|
107
|
+
- **`Wire.http_for` — the one place http vs https is decided, read off the target's scheme.** `Client` could not dial a TLS origin at all, so `Runner` reached none.
|
|
108
|
+
|
|
109
|
+
- **`Client#query` and `#run` take `headers:`.** A beat that attacks with a request header — a declared clock, or a source an operator must not read one from — could not send one.
|
|
110
|
+
- **`Scenarios::TokenTampering` probes a verb the origin actually ROUTES.** It used to dial a made-up name, which an origin drawing one explicit route per verb answers with a routing 404 — decided before any credential is read — so the beat scored a refusal the auth check never made. It now dials the profile's `per_user_query`, and SKIPS with a sentence when a profile declares none rather than certifying a check that did not run.
|
|
111
|
+
- **`Scenarios::WrongCurrencyCart` — the cashier check that was hand-copied into three demos.** `kiosk-server` verifies that intent, cart and payment agree with each other; it has no opinion about what those agreeing numbers MEAN, because the catalogue is the operator's. So a cart whose every link says the same foreign currency is internally perfect and still has to be refused at capture, or a caller sets the unit of account. The three commerce demos each carried a byte-identical local scenario asserting it, with the currencies written into the source; the gem's version reads the operator's own from the new `Profile#currency` and probes with a currency that is NOT it, so an origin that prices in dollars is not probed with dollars and cannot print BLOCKED for a cart that was never foreign.
|
|
112
|
+
|
|
113
|
+
- **`Wire` and `Battery` — the half of a red-team suite that was not in the gem.** A provider's battery is never all library: the interesting attacks are on that provider's own verbs, and until now writing them meant hand-rolling an HTTP helper, a result ledger, a printed vocabulary and an exit block beside the gem rather than on top of it. `Wire` is the raw wire an attack on the REQUEST needs — arbitrary method, arbitrary path, arbitrary headers, response headers readable, a non-JSON body reading as `{}` and an unreachable origin as status `0` so a hostile answer is asserted on instead of crashing the run. `Battery` is one ledger for hand-written beats and library scenarios together, printing both in one vocabulary and answering one exit status: 0 only when at least one attack ran and every attack that ran was blocked, 1 on a breach or on a battery that proved nothing, 2 when the skips are not the ones the caller expected. `on_skip: :breach` files a skip as a finding for a scenario whose surface this origin definitely has.
|
|
114
|
+
|
|
115
|
+
- **`LeakScan` — the leak oracle every hostile-input beat asks, made a function of what the APP said rather than of what the ATTACKER sent (T-121).** Each demo's battery asserts that a refusal carries no runtime vocabulary by substring-searching the serialized body for `PG::`, `NoMethodError` and their siblings, while every demo answers a bad argument by NAMING the value it got — so a probe whose value spelled a needle would have been reported as a BREACH on its own echoed bytes, under runners whose own prose tells the reader a BREACH means «fix the app, not the scenario». The scan is POSITIONAL rather than subtractive: it records where the probe's own value occurs in the body and discounts a needle only when those exact bytes lie wholly inside ONE such run. A `gsub` of the supplied value was rejected and the reason is executable in the spec — it deletes by value everywhere, so a probe supplying `input syntax` erases the needle out of a genuine `invalid input syntax` leak, which is a false NEGATIVE where the defect being fixed only ever produced false positives. Discounted needles are REPORTED rather than swallowed, because when a probe supplies a needle verbatim no content-only oracle can separate it from one the app produced; and `supplied:` defaults to nothing, so a beat that forgets to declare degrades to the old behaviour — a possible false BREACH, never a missed leak.
|
|
116
|
+
|
|
117
|
+
- **`Scenarios::DeviceGrantRoleSelfSelection` — the account-binding claim ceremony's role beat, for every provider (K-1128).** `PrivilegeSelfSelection` covers `/auth/register`, where the role was never client-readable; the door that was actually open was the UNAUTHENTICATED `POST <endpoint>/oauth/device_authorization`, whose `role`/`scope` reached the minted JWT with membership of `config.roles` as the only filter (K-072). The new scenario asserts that request refuses both spellings — at a role the origin genuinely DECLARES, which is the probe with teeth, since an invented one was refused by the vulnerable code too and is why a battery could print BLOCKED over a live escalation for nineteen days — while the role-less request still opens the ceremony. It reads a declared role off the wire (the `role` claim of a token the origin itself mints at registration) as well as from the new `Profile#declared_roles`, so a stale profile weakens the probe rather than emptying it. `Client#device_authorization` is the form-encoded driver it needs; the OAuth half of the ceremony answers RFC 6749 `{error, error_description}` rather than a Kiosk problem document, so `Redteam.blocked?` cannot judge it and the scenario names the status and error value it demands.
|
|
118
|
+
|
|
119
|
+
- `Kiosk::Redteam::Client` — HTTP client for the wire surface an attacker sees: agent register/login (solving the Equihash registration toll), KYC attestation, and the `query` / `run` / `pay` verbs with RS256 mandate signing.
|
|
120
|
+
- `Kiosk::Redteam::Scenario` / `Verdict` / `Runner` — the harness. A scenario runs one hostile flow and returns a `Verdict` (blocked / skipped, status, detail); a scenario that finds a real breach fails loudly rather than reporting a pass.
|
|
121
|
+
- `Kiosk::Redteam::Principal` / `Response` — the value types scenarios work with: a registered agent identity carrying its RSA key so mandates can be signed or forged, and a parsed HTTP response.
|
|
122
|
+
- `Kiosk::Redteam::Profile` — per-provider parameterisation (PoW difficulty, KYC requirement, the queries and actions to attack, mandate builders), so one scenario library runs against any Kiosk provider.
|
|
123
|
+
- Generic attack scenario library: cross-tenant read, forged user id, privilege self-selection, mandate principal swap, mandate replay, token tampering, missing / expired / forged KYC, unpaid gated action, pay-for-other-use-self, spent-resource reuse, and registration without PoW.
|
|
124
|
+
- `base64` declared as a runtime dependency — `scenario.rb` and `scenarios/privilege_self_selection.rb` require it at load time, and until then it arrived only by accident, as a transitive dependency of `jwt` (it stopped being a default gem in Ruby 3.4).
|
|
125
|
+
|
|
126
|
+
### Changed
|
|
127
|
+
|
|
128
|
+
- **The verdict headers stop sending a reader to an INDETERMINATE state this gem never had.** There are three verdicts; an answer that proved nothing is told by its `detail`, not by a fourth.
|
|
129
|
+
|
|
130
|
+
- **The rubygems blurb stops listing HTTP 402 among the statuses that constitute a block.** The predicate, the README and `verdict_from` dropped 402 long ago; the blurb is read first.
|
|
131
|
+
|
|
132
|
+
- **`Scenarios::WrongCurrencyCart` names `403` instead of delegating to `blocked?`.** Delegating admitted a `401`, which says the credential was rejected rather than that the cashier refused the cart — a refusal scored for an attack that never reached the counter. Same reason the gem already declines to delegate a bare `402`.
|
|
133
|
+
|
|
134
|
+
- README: every `gem` line in the install section now carries `github: "kiosk-hq/kiosk"`, so a copied line resolves before publication; the banner above them states what the block does rather than asking the reader to add it.
|
|
135
|
+
- The `pow_required` explanation and the device-grant scenario's
|
|
136
|
+
control-registration refusal, both printed by a battery run, now say what the
|
|
137
|
+
condition is instead of naming an internal tracker row.
|
|
138
|
+
- **A TOLLED VERB CAN NOW BE ATTACKED (K-760).** `#query`, `#run`, `#pay` and `#pay_raw` route their answer through one shared, bounded 402-PoW retry — the same `Client#with_pow_retry` registration uses — instead of leaving the solve branch inlined in `#register_raw` where only registration could reach it. A toll is a price, not a refusal (K-736), so an attacker pays it; a harness that could not pay it could not run the attack at all. Measured against getgrocery with its catalog toll ON (`KIOSK_POW_DEMO=1`): before, the battery ABORTED on its first scenario (`catalog returned empty`) and produced no verdicts; after, 17 BLOCKED / 3 SKIPPED / 0 BREACH, byte-identical to the untolled run. Exactly ONE solve-and-resend per call, never a loop: a re-demanded toll comes back flagged `pow_retried` and reads as a could-not-test verdict that says the toll was already paid, which is a statement about the provider rather than about this gem. The retry re-sends the IDENTICAL request — `#pay` signs its mandates once and reuses the body, because the challenge binds to a fingerprint of method + verb + body and a re-signed mandate would be a different request.
|
|
139
|
+
|
|
140
|
+
- The client speaks protocol 0.4: `#query` is `GET <endpoint>/<query-name>` with its arguments in the query string, `#run` is `POST <endpoint>/<action-name>` with the arguments as the whole body, and there is no `name` field on the wire. Error codes are read off the top level of an RFC 9457 problem document rather than out of the retired `error` envelope.
|
|
141
|
+
|
|
142
|
+
- **A BLOCKED verdict now names the gate it proved.** `verdict_from` takes `expect:` / `expect_code:`, so a scenario demands the status and denial code that constitute a refusal of ITS attack instead of accepting any of 401/402/403 interchangeably; the Runner prints the status on the BLOCKED line, and `all_blocked?` refuses to go green on a battery in which nothing was exercised. What a green battery means is stricter than it was: verdicts that used to pass on an unrelated gate's refusal, on a crash, or on a query that was never answered now fail.
|
|
143
|
+
- The registration gate the client solves is Equihash, not the SHA256 hashcash the first version assumed — client, docstrings and gemspec now describe the shipped gate, and the dead hashcash helper is gone.
|
|
144
|
+
- The proof travels in a `Kiosk-PoW` request header as raw JSON rather than as a body field.
|
|
145
|
+
- `jwt` widened to `>= 2.0, < 4.0` so hosts on jwt 3.x can run the harness.
|
|
146
|
+
|
|
147
|
+
### Fixed
|
|
148
|
+
|
|
149
|
+
- `Scenario#rows_from` read only the paginated `{rows:, next:}` shape, so a non-paginating query's BARE ARRAY answer — the ordinary one on the 0.4 wire — decoded as no rows at all. `ForgedUserId`'s ownership check would then have read "not leaked" and scored a **vacuous BLOCKED** against an origin it never tested.
|
|
150
|
+
- `ForgedUserId#extract_id` read the deleted 0.3 `value` wrapper, so on any real origin it found no resource id and every run ended "cannot confirm ownership was enforced".
|
|
151
|
+
- `ForgedUserId` now scores the typed `400 bad_request` a 0.4 origin answers — the refusal that NAMES the injected `user_id`, because a verb whose principal comes from the token does not declare it — as BLOCKED. Without that branch the scenario reported a BREACH against a provider doing exactly the right thing. The check is in the scenario, not in `blocked?`: what makes this 400 evidence is that it names the property we injected, which a generic predicate cannot see.
|
|
152
|
+
|
|
153
|
+
- Six ways a scenario could report a pass it had not earned: `CrossTenantRead` scored a 404/402/500 on B's query as isolation and had no control proving the query returns anything for its owner; the two registration scenarios passed against a server that 404s every path; the KYC scenarios discarded the payment they staged, so the payment gate answered in the KYC gate's name; `PayForOtherUseSelf` reported a card decline or an expired token as the ownership gate and never attempted the attack; and an all-skip battery exited 0. Each now asserts what it staged and names the gate it demands.
|
|
154
|
+
- A crash can no longer masquerade as enforcement through the denial-code path: `Kiosk::Redteam.blocked?` applies its 5xx/connection-error rule to the `error.code` branch as well, which had none.
|
|
155
|
+
- Neither can a toll: `blocked?` counted a bare HTTP 402 as "explicit auth/authz rejection" although kiosk-server shares that status between `pow_required`, `payment_setup_required` and `payment_failed` — so a tolled verb printed `BLOCKED ✓ … (HTTP 402)` for an attack the harness never ran, since it solves proof-of-work only during registration. A 402 (and a `pow_required` envelope on any status) now yields a could-not-test verdict that names which of the three answered and fails the battery instead of passing it; a scenario that genuinely means a payment gate names the code it accepts with `verdict_from(expect_code:)`.
|
|
156
|
+
- A skipped scenario reports a real skipped state instead of a pass, an inapplicable scenario is asserted as such, and `bad_request` no longer counts as "blocked" — three ways the harness could previously report green without having proved anything.
|
|
157
|
+
- The client locates the Equihash solver through `Kiosk::Pow::Equihash.solver_path`, with `kiosk-pow-equihash` now a declared runtime dependency — the previous monorepo-relative filesystem reach meant an installed `kiosk-redteam` raised `Errno::ENOENT` the first time a scenario had to solve a registration challenge.
|
|
158
|
+
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# kiosk-redteam
|
|
2
|
+
|
|
3
|
+
Adversarial regression harness for [Kiosk](https://kiosk.tech) providers — it
|
|
4
|
+
drives hostile HTTP scenarios against a running Kiosk origin and asserts each
|
|
5
|
+
attack is correctly blocked.
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
8
|
+
|
|
9
|
+
A scenario registers its own principals over the wire, stages whatever state the
|
|
10
|
+
attack needs, then performs the attack and returns a `Verdict`. A scenario that
|
|
11
|
+
finds a real breach fails loudly: `Battery#report!` answers 1 and the
|
|
12
|
+
caller exits non-zero. Fix the provider, keep the scenario as a permanent
|
|
13
|
+
regression.
|
|
14
|
+
|
|
15
|
+
**No Rails.** The harness speaks the wire and nothing else, so
|
|
16
|
+
it can be pointed at any Kiosk origin — your own app in CI, or a third party's
|
|
17
|
+
deployment. Everything provider-specific (which verbs exist, how to create an
|
|
18
|
+
owned row, how to build a mandate) lives in a `Profile` you supply; no provider
|
|
19
|
+
name is hard-coded in the gem.
|
|
20
|
+
|
|
21
|
+
**`http` or `https` is decided by the base URL you pass and by nothing else.**
|
|
22
|
+
There is no TLS flag and no environment variable: the scenarios attack through
|
|
23
|
+
`Kiosk::TestHelpers::Assistant` and `Kiosk::TestHelpers::Wire` from
|
|
24
|
+
`kiosk-test-support`, which read the scheme off the target. So `base_url:
|
|
25
|
+
"http://127.0.0.1:3000"` is a local app and `base_url:
|
|
26
|
+
"https://example.com"` is that deployment, with the same code and the same
|
|
27
|
+
profile. Point it at a deployment you do not own and remember what a battery
|
|
28
|
+
is: scenarios REGISTER principals and STAGE the state their attack needs, so
|
|
29
|
+
run it against something you are willing to have written to.
|
|
30
|
+
|
|
31
|
+
### Blocked, breached, untested, skipped — the four states
|
|
32
|
+
|
|
33
|
+
| Verdict | Means | Printed |
|
|
34
|
+
|---|---|---|
|
|
35
|
+
| **blocked** | the provider refused this attack | `BLOCKED ✓ <name> (HTTP <status>)` |
|
|
36
|
+
| **breach** | the attack was NOT refused — a real finding | `BREACH ✗ <name> — <detail>` |
|
|
37
|
+
| **untested** | a setup step or the environment failed, so the attack never reached its gate | `UNTESTED ! <name> — <detail>` |
|
|
38
|
+
| **skipped** | the profile lacks the surface this scenario needs | `SKIP — <name> (<reason>)` |
|
|
39
|
+
|
|
40
|
+
An untested attack is **not** a pass and **not** a breach: `Battery#report!`
|
|
41
|
+
answers 1, and the detail names the step that failed. A payment processor the
|
|
42
|
+
origin cannot reach gives this state: the origin answers `payment_setup_required`
|
|
43
|
+
before it reads the mandates. A skip does not count towards the blocked total,
|
|
44
|
+
and `Battery#report!` refuses to go green on a battery that produced no proofs
|
|
45
|
+
at all, so a profile that skips everything cannot exit 0.
|
|
46
|
+
|
|
47
|
+
What counts as a refusal is deliberately narrow. HTTP 401/403 count, and so do
|
|
48
|
+
the problem document `code`s `forbidden` / `unauthenticated` / `rls_denied`.
|
|
49
|
+
**5xx never counts** — a crash must not masquerade as an enforcement gate. Nor
|
|
50
|
+
does **402**: `kiosk-server` maps three codes onto that status
|
|
51
|
+
(`pow_required`, `payment_setup_required`, `payment_failed`) and none of them is
|
|
52
|
+
a refusal of the attack. The origin answers `pow_required` and
|
|
53
|
+
`payment_setup_required` before it evaluates the request, so they give an
|
|
54
|
+
untested verdict unless the scenario named the code it accepts. A
|
|
55
|
+
`payment_failed` comes after every gate said yes, so it is a breach. A scenario that knows which gate must fire
|
|
56
|
+
says so with `expect:` / `expect_code:` rather than leaning on the permissive
|
|
57
|
+
default.
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
> **Not on RubyGems yet** — so every `gem` line below carries `github: "kiosk-hq/kiosk"`, which is what makes it copy-pasteable today. Publication status and the canonical install are stated once, in the monorepo README's [Install](https://github.com/kiosk-hq/kiosk#install) section.
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
# Gemfile — a test/CI dependency, not a runtime one
|
|
65
|
+
gem "kiosk-redteam", github: "kiosk-hq/kiosk", group: :development
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The registration toll is real Equihash: the assistant client solves the server's
|
|
69
|
+
402 challenges with the reference solver that ships inside `kiosk-pow-equihash`,
|
|
70
|
+
so the machine running the battery needs **`python3` with `numpy`** on `PATH`. Point a battery at an
|
|
71
|
+
origin whose PoW is off and nothing is solved and nothing is needed.
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
Describe the provider once, hand the runner a list of scenarios, exit on the
|
|
76
|
+
verdict:
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
require "kiosk/redteam"
|
|
80
|
+
|
|
81
|
+
SERVER = ENV.fetch("SERVER_URL", "http://127.0.0.1:3000")
|
|
82
|
+
|
|
83
|
+
profile = Kiosk::Redteam::Profile.new(
|
|
84
|
+
# >0 means this origin is expected to gate /auth/register with a toll.
|
|
85
|
+
pow_difficulty: 1,
|
|
86
|
+
# The roles this origin declares (Kiosk.configuration.roles), as strings.
|
|
87
|
+
declared_roles: %w[customer],
|
|
88
|
+
# The named query that returns the caller's OWN rows.
|
|
89
|
+
per_user_query: "my_orders",
|
|
90
|
+
# Key in a returned row that holds the row id, and in an action's own
|
|
91
|
+
# response object (they often differ).
|
|
92
|
+
row_id_key: "id",
|
|
93
|
+
result_id_key: "order_id",
|
|
94
|
+
# Create a row owned by `principal`; must return a Hash with at least :id.
|
|
95
|
+
create_owned: ->(client, principal) {
|
|
96
|
+
resp = client.run(principal, name: "create_order", items: [{ sku: "SKU-1", qty: 1 }])
|
|
97
|
+
raise "create_order failed (#{resp.status}): #{resp.body.inspect}" unless resp.status == 200
|
|
98
|
+
{ id: resp.body.fetch("order_id") }
|
|
99
|
+
},
|
|
100
|
+
# An action that takes a `user_id` argument the server must NOT honour.
|
|
101
|
+
forge_action: "create_order",
|
|
102
|
+
forge_args: ->(_client, _a, _b) { { items: [{ sku: "SKU-1", qty: 1 }] } },
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
runner = Kiosk::Redteam::Runner.new(base_url: SERVER, profile:)
|
|
106
|
+
battery = Kiosk::Redteam::Battery.new
|
|
107
|
+
battery.absorb(runner.run([
|
|
108
|
+
Kiosk::Redteam::Scenarios::CrossTenantRead.new,
|
|
109
|
+
Kiosk::Redteam::Scenarios::ForgedUserId.new,
|
|
110
|
+
Kiosk::Redteam::Scenarios::TokenTampering.new,
|
|
111
|
+
Kiosk::Redteam::Scenarios::RegistrationWithoutPow.new,
|
|
112
|
+
Kiosk::Redteam::Scenarios::DeviceGrantRoleSelfSelection.new,
|
|
113
|
+
]))
|
|
114
|
+
|
|
115
|
+
exit battery.report!
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Every field of `Profile` is optional; a scenario whose field is `nil` skips
|
|
119
|
+
itself rather than inventing a surface. That is what lets one battery cover a
|
|
120
|
+
commerce provider and a non-commerce one. `suites/` holds one battery per
|
|
121
|
+
operator demo in this repo, built on this API — read one of those for a worked,
|
|
122
|
+
running profile against a real origin. Each runs in its demo's directory, with
|
|
123
|
+
that demo's bundle. A demo that takes payments charges a stripe-mock: start the
|
|
124
|
+
demo's server with `STRIPE_MOCK_URL` set to the URL of a running
|
|
125
|
+
`Kiosk::TestHelpers::StripeMock` relay, as CI does. stripe-mock alone answers
|
|
126
|
+
each charge as unpaid. When the server cannot reach the relay, the payment
|
|
127
|
+
attacks are untested.
|
|
128
|
+
|
|
129
|
+
## The scenario library
|
|
130
|
+
|
|
131
|
+
The classes under `Kiosk::Redteam::Scenarios`, each parameterised entirely by
|
|
132
|
+
the profile — this is the whole library. `lib/kiosk/redteam/scenarios/` has one
|
|
133
|
+
file per row, plus `kyc_attack.rb`, the `KycAttack` module that the KYC
|
|
134
|
+
scenarios share:
|
|
135
|
+
|
|
136
|
+
| Scenario | Asserts |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `CrossTenantRead` | B's per-user query must not return rows owned by A |
|
|
139
|
+
| `ForgedUserId` | a caller-supplied `user_id` never decides ownership |
|
|
140
|
+
| `PrivilegeSelfSelection` | a client-chosen registration role is ignored — the role is server-pinned |
|
|
141
|
+
| `DeviceGrantRoleSelfSelection` | the claim ceremony's unauthenticated opening request refuses `role`/`scope`, at a DECLARED value as well as an invented one |
|
|
142
|
+
| `SpentResourceReuse` | a consumed resource cannot be re-activated |
|
|
143
|
+
| `PayForOtherUseSelf` | B paying for A's resource does not let B use it |
|
|
144
|
+
| `TokenTampering` | a JWT with a flipped claim and the original signature is 401 |
|
|
145
|
+
| `RegistrationWithoutPow` | a missing or bad proof is rejected when the origin charges a toll |
|
|
146
|
+
| `MandatePrincipalSwap` | B signing a mandate that carries A's identity is rejected |
|
|
147
|
+
| `MandateReplay` | A's signed mandate JWS re-submitted under B's token is rejected |
|
|
148
|
+
| `UnpaidGatedAction` | the gated action without a prior settled payment is denied |
|
|
149
|
+
| `WrongCurrencyCart` | a chain-consistent cart denominated in a currency the operator does not price in is refused at capture |
|
|
150
|
+
| `MissingKyc` | the gated action after payment but without an attestation is denied |
|
|
151
|
+
| `ExpiredKyc` | an attestation whose `exp` has passed is rejected |
|
|
152
|
+
| `ForgedKyc` | an attestation with a wrong issuer or a bad signature is rejected |
|
|
153
|
+
|
|
154
|
+
Beside them the gem ships `Profile`, `Scenario`, `Verdict`, `Runner`,
|
|
155
|
+
`Battery` and `LeakScan`, which decides whether a refusal leaked the runtime's
|
|
156
|
+
own vocabulary, discounting needles the attack itself supplied. A scenario
|
|
157
|
+
receives a `Kiosk::TestHelpers::Assistant` — register, query, run, pay with
|
|
158
|
+
signed mandates, kyc, and the device-authorization request — and its
|
|
159
|
+
`events(principal)` is the assistant's side of `<endpoint>/events`.
|
|
160
|
+
|
|
161
|
+
## Your own beats, in the same battery
|
|
162
|
+
|
|
163
|
+
No provider's battery is all library. The scenarios above are the attacks every
|
|
164
|
+
Kiosk origin has to survive; the interesting half is always the attacks on
|
|
165
|
+
*your* verbs — your enum filters, your price arithmetic, your ownership joins.
|
|
166
|
+
Two classes carry that half, and they are the reason a hand-written beat and a
|
|
167
|
+
library scenario can sit in one run.
|
|
168
|
+
|
|
169
|
+
`Kiosk::TestHelpers::Wire` is the raw wire: an arbitrary method at an arbitrary path with arbitrary
|
|
170
|
+
headers, which is what an attack on the REQUEST rather than on the principal
|
|
171
|
+
needs — a forged or absent `Authorization`, a verb nobody registered, the wrong
|
|
172
|
+
method at a real verb's path, an assertion on `Allow:` rather than on a body. A
|
|
173
|
+
body that is not JSON reads as `{}` and a connection error reads as status `0`,
|
|
174
|
+
so a hostile answer is asserted on instead of crashing the run; the bytes stay
|
|
175
|
+
available on `raw_body` for a `LeakScan`.
|
|
176
|
+
|
|
177
|
+
`Battery` is one ledger, one printed vocabulary and one exit status for the
|
|
178
|
+
whole run — hand-written beats and library scenarios together:
|
|
179
|
+
|
|
180
|
+
```ruby
|
|
181
|
+
wire = Kiosk::TestHelpers::Wire.new(base_url: SERVER)
|
|
182
|
+
client = Kiosk::TestHelpers::Assistant.new(base_url: SERVER)
|
|
183
|
+
battery = Kiosk::Redteam::Battery.new
|
|
184
|
+
|
|
185
|
+
# your own beat, against your own verb
|
|
186
|
+
status, rows = wire.get_json("/kiosk/my_listings", {}, wire.bearer(bob.token))
|
|
187
|
+
battery.record("CrossTenantRead", status == 200 && !ids(rows).include?(alice_row),
|
|
188
|
+
"Bob's rows #{ids(rows).inspect} exclude Alice's #{alice_row}")
|
|
189
|
+
|
|
190
|
+
# a library scenario, in the same ledger
|
|
191
|
+
battery.scenario(Kiosk::Redteam::Scenarios::DeviceGrantRoleSelfSelection.new,
|
|
192
|
+
client:, profile:, on_skip: :breach)
|
|
193
|
+
|
|
194
|
+
# a whole Runner battery, in the same ledger
|
|
195
|
+
battery.absorb(runner.run(scenarios))
|
|
196
|
+
|
|
197
|
+
exit battery.report!(expected_skips: %w[MissingKyc ExpiredKyc])
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`report!` prints the summary, returns the process exit status and never lets a
|
|
201
|
+
run that proved nothing read as green: **0** when at least one attack ran and
|
|
202
|
+
every attack that ran was blocked, **1** on a breach, on an untested attack or
|
|
203
|
+
on a battery with no proofs at all, **2** when every attack that ran was
|
|
204
|
+
blocked but the set of skips is not `expected_skips` — a profile key that silently went `nil` disables a gate
|
|
205
|
+
scenario, and that must not pass as a clean run.
|
|
206
|
+
|
|
207
|
+
Pass `on_skip: :breach` for a scenario whose surface this origin definitely
|
|
208
|
+
has: there, a skip is a defect of the harness rather than a property of the
|
|
209
|
+
provider, and a quiet skip is how a beat that stopped running goes unnoticed.
|
|
210
|
+
|
|
211
|
+
Pass `untested: true` to `record` when a setup step of your beat failed. The
|
|
212
|
+
attack did not reach its gate, so the beat is UNTESTED and the run fails with
|
|
213
|
+
no BREACH.
|
|
214
|
+
|
|
215
|
+
### Writing your own
|
|
216
|
+
|
|
217
|
+
Subclass `Scenario`, name what you are attacking, and return a `Verdict` that
|
|
218
|
+
says which gate you demanded:
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
class UnknownVerbIs404 < Kiosk::Redteam::Scenario
|
|
222
|
+
def initialize
|
|
223
|
+
super(name: "UnknownVerbIs404")
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def call(client, profile)
|
|
227
|
+
principal = client.register!
|
|
228
|
+
verdict_from(client.query(principal, name: "no_such_verb"), expect: 404)
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Status
|
|
234
|
+
|
|
235
|
+
Pre-v1.0 alpha. The `Scenario` / `Profile` / `Verdict` surface is stable across
|
|
236
|
+
pre-v1.0 minor bumps; the scenario library grows as gates are added
|
|
237
|
+
(`CHANGELOG.md` tracks).
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
Apache-2.0 — see `LICENSE.txt`.
|
|
242
|
+
|
|
243
|
+
## Links
|
|
244
|
+
|
|
245
|
+
- [kiosk.tech](https://kiosk.tech) — landing + docs
|
|
246
|
+
- [Specification](https://kiosk.tech/specification.html) — the normative spec
|
|
247
|
+
- [Issue tracker](https://github.com/kiosk-hq/kiosk/issues)
|