@keelcodes/conformance 0.1.0
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/LICENSE +201 -0
- package/README.md +187 -0
- package/dist/abi.d.ts +219 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +41 -0
- package/dist/abi.js.map +1 -0
- package/dist/agents.d.ts +24 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +161 -0
- package/dist/agents.js.map +1 -0
- package/dist/checks.d.ts +12 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +168 -0
- package/dist/checks.js.map +1 -0
- package/dist/delegation.d.ts +40 -0
- package/dist/delegation.d.ts.map +1 -0
- package/dist/delegation.js +245 -0
- package/dist/delegation.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/permissions.d.ts +52 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +189 -0
- package/dist/permissions.js.map +1 -0
- package/dist/reader.d.ts +9 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +58 -0
- package/dist/reader.js.map +1 -0
- package/dist/redteam.d.ts +38 -0
- package/dist/redteam.d.ts.map +1 -0
- package/dist/redteam.js +190 -0
- package/dist/redteam.js.map +1 -0
- package/dist/report.d.ts +4 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +29 -0
- package/dist/report.js.map +1 -0
- package/dist/runner.d.ts +8 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +62 -0
- package/dist/runner.js.map +1 -0
- package/dist/types.d.ts +227 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Keel contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# @keelcodes/conformance
|
|
2
|
+
|
|
3
|
+
Cross-ecosystem **conformance and security suite** for agent accounts — the
|
|
4
|
+
neutral, spec-anchored layer that answers one question: *does this ERC-7579
|
|
5
|
+
account (and the modules installed on it) actually behave the way the standard
|
|
6
|
+
says?*
|
|
7
|
+
|
|
8
|
+
It is deliberately free of Keel-specific dependencies: a check talks to a small
|
|
9
|
+
`AccountReader` port, so the same suite runs against an in-memory fake in tests or
|
|
10
|
+
a live chain via `createViemReader`. Any team can point it at their own account.
|
|
11
|
+
|
|
12
|
+
## Status
|
|
13
|
+
|
|
14
|
+
| Suite | Coverage |
|
|
15
|
+
|---|---|
|
|
16
|
+
| **ERC-7579** | ✅ core account surface + module install/uninstall lifecycle + type validation |
|
|
17
|
+
| **ERC-7710** | ✅ delegation hash / domain binding / reference getters |
|
|
18
|
+
| **ERC-7715** | ✅ wallet capability discovery + granted-permission shape |
|
|
19
|
+
| **ERC-8004** | ✅ identity (ERC-721) + agent wallet + reputation binding |
|
|
20
|
+
| **Red-team** | ✅ `KeelPolicyHook` adversarial cases, mapped to `T-*` threat ids |
|
|
21
|
+
|
|
22
|
+
See [`docs/CONFORMANCE.md`](../../docs/CONFORMANCE.md) for the full matrix and
|
|
23
|
+
[`docs/THREAT_MODEL.md`](../../docs/THREAT_MODEL.md) for the threat catalogue.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { createPublicClient, http } from 'viem';
|
|
29
|
+
import { ERC7579_SUITE, createViemReader, formatReport, runSuite } from '@keelcodes/conformance';
|
|
30
|
+
|
|
31
|
+
const client = createPublicClient({ transport: http('https://bsc-testnet-rpc.publicnode.com') });
|
|
32
|
+
|
|
33
|
+
const report = await runSuite(
|
|
34
|
+
{
|
|
35
|
+
reader: createViemReader(client),
|
|
36
|
+
account: '0x…', // the smart account under test
|
|
37
|
+
module: '0x…', // the module you expect to be installed
|
|
38
|
+
moduleTypeId: 4n, // ERC-7579 module type (4 = hook)
|
|
39
|
+
},
|
|
40
|
+
ERC7579_SUITE,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
console.log(formatReport(report));
|
|
44
|
+
// FAIL · ERC-7579 · 9 checks · account 0x… · module 0x… · type 4
|
|
45
|
+
// ✓ !! erc7579.account.deployed — account has bytecode
|
|
46
|
+
// ✗ !! erc7579.module.initialized — module is installed but reports isInitialized == false …
|
|
47
|
+
// 8 passed · 1 failed (1 critical) · 3ms
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Every read is a `view` call, so a read-only client is enough. The two module
|
|
51
|
+
**lifecycle** checks mutate state (install/uninstall), so they need a second,
|
|
52
|
+
explicitly injected `moduleAdmin` port; without it they fail with a clear
|
|
53
|
+
"needs reader, moduleAdmin …" message rather than silently skipping — a run is
|
|
54
|
+
read-only unless you opt in. `erc7579.module.isModuleType` is a plain read and
|
|
55
|
+
needs no extra port.
|
|
56
|
+
|
|
57
|
+
Other suites bind their own port instead of the account fields:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { ERC7710_SUITE, createViemDelegationReader } from '@keelcodes/conformance';
|
|
61
|
+
|
|
62
|
+
const delegation = await runSuite(
|
|
63
|
+
{ delegation: createViemDelegationReader(client, manager) },
|
|
64
|
+
ERC7710_SUITE,
|
|
65
|
+
);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## The checks
|
|
69
|
+
|
|
70
|
+
| id | severity | asserts |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| `erc7579.account.deployed` | critical | the account has bytecode |
|
|
73
|
+
| `erc7579.account.supportsSingleMode` | high | `supportsExecutionMode` for callType `0x00` |
|
|
74
|
+
| `erc7579.account.supportsBatchMode` | high | `supportsExecutionMode` for callType `0x01` |
|
|
75
|
+
| `erc7579.account.accountId` | medium | `accountId()` is non-empty |
|
|
76
|
+
| `erc7579.module.installed` | critical | `isModuleInstalled(moduleTypeId, module, 0x)` is true |
|
|
77
|
+
| `erc7579.module.initialized` | critical | the module's own `isInitialized(account)` is true |
|
|
78
|
+
| `erc7579.module.installUninstallFlow` | critical | `installModule` registers the module, `uninstallModule` removes it |
|
|
79
|
+
| `erc7579.module.onInstallOnUninstall` | high | `onInstall` / `onUninstall` took effect (`isInitialized` tracks the lifecycle) |
|
|
80
|
+
| `erc7579.module.isModuleType` | high | `isModuleType` is true only for the module's own type (all four ids probed) |
|
|
81
|
+
|
|
82
|
+
`erc7579.module.installed` + `erc7579.module.initialized` are the two halves of the
|
|
83
|
+
**migration probe**: an install can register a module on the account while the
|
|
84
|
+
module's `onInstall` silently no-ops (e.g. a mismatched `initData` layout). Both
|
|
85
|
+
assertions must hold, otherwise the account looks configured while the module
|
|
86
|
+
enforces nothing — a silent AA24-class failure.
|
|
87
|
+
|
|
88
|
+
### ERC-7710 — delegation
|
|
89
|
+
|
|
90
|
+
| id | severity | asserts |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| `erc7710.manager.deployed` | critical | the `DelegationManager` has bytecode |
|
|
93
|
+
| `erc7710.manager.domainBinding` | high | `getDomainHash()` equals the EIP-712 preimage for **this** chain + manager |
|
|
94
|
+
| `erc7710.manager.delegationHash` | critical | `getDelegationHash()` equals our off-chain derivation |
|
|
95
|
+
| `erc7710.manager.signatureIgnored` | high | changing `signature` does not change the hash |
|
|
96
|
+
| `erc7710.manager.rootAuthority` | medium | `ROOT_AUTHORITY()` is the all-ones sentinel |
|
|
97
|
+
| `erc7710.manager.anyDelegate` | medium | `ANY_DELEGATE()` is the reference wildcard |
|
|
98
|
+
| `erc7710.manager.notDisabledByDefault` | high | a fresh delegation reads as enabled |
|
|
99
|
+
|
|
100
|
+
The EIP body fixes only `redeemDelegations`; the getters probed here are the
|
|
101
|
+
MetaMask delegation-framework reference the EIP names. The suite's core value is
|
|
102
|
+
**off-chain / on-chain agreement** on the hash and domain separator — a mismatch
|
|
103
|
+
is a cross-chain or cross-contract replay vector.
|
|
104
|
+
|
|
105
|
+
### ERC-7715 — permissions
|
|
106
|
+
|
|
107
|
+
| id | severity | asserts |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `erc7715.wallet.capabilityDiscovery` | high | `wallet_getSupportedExecutionPermissions` advertises at least one type |
|
|
110
|
+
| `erc7715.wallet.chainIdFormat` | medium | advertised chain ids are `0x` hex |
|
|
111
|
+
| `erc7715.wallet.grantedResponseShape` | high | `wallet_getGrantedExecutionPermissions` matches `PermissionResponse` |
|
|
112
|
+
| `erc7715.wallet.delegationManagerBound` | high | a granted permission redeems via the expected manager (cross-checked with ERC-7710) |
|
|
113
|
+
|
|
114
|
+
ERC-7715 is a **wallet JSON-RPC** standard (EIP-1193 `request`), not on-chain;
|
|
115
|
+
execution lands on ERC-7710's `redeemDelegations`.
|
|
116
|
+
|
|
117
|
+
### ERC-8004 — agent registry
|
|
118
|
+
|
|
119
|
+
| id | severity | asserts |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `erc8004.identity.deployed` | critical | the identity registry has bytecode |
|
|
122
|
+
| `erc8004.identity.erc721` | high | `supportsInterface(ERC-721)` is true |
|
|
123
|
+
| `erc8004.identity.agentRegistered` | critical | `ownerOf(agentId)` is non-zero |
|
|
124
|
+
| `erc8004.identity.agentURI` | medium | `tokenURI(agentId)` resolves to something |
|
|
125
|
+
| `erc8004.identity.agentWallet` | high | `getAgentWallet(agentId)` is non-zero |
|
|
126
|
+
| `erc8004.reputation.bound` | high | the reputation registry points at the identity registry |
|
|
127
|
+
|
|
128
|
+
### Red-team — adversarial cases
|
|
129
|
+
|
|
130
|
+
The Foundry red-team suite (`contracts/test/redteam/KeelPolicyHook.redteam.t.sol`)
|
|
131
|
+
is surfaced through the *same* report machinery. Each case is mapped explicitly
|
|
132
|
+
to a `T-*` threat id from [`THREAT_MODEL.md`](../../docs/THREAT_MODEL.md) §4, via
|
|
133
|
+
an injectable `RedTeamPort` (a `testName → passed` table):
|
|
134
|
+
|
|
135
|
+
| id | severity | asserts (Foundry case) |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `redteam.t-bypass-01…06` | critical | delegatecall / unknown selector / `transferFrom` / short calldata / widened whitelist / unauthorised target are all refused |
|
|
138
|
+
| `redteam.t-ceiling-01/02` | high | a batch cannot split around a native or token daily cap |
|
|
139
|
+
| `redteam.t-accrual-01/02` | high | a session cannot be re-installed to reset counters, nor charged by a foreign caller |
|
|
140
|
+
| `redteam.t-window-01` | high | an expired session is refused |
|
|
141
|
+
| `redteam.t-lifecycle-01` | critical | an uninstalled session cannot be used |
|
|
142
|
+
|
|
143
|
+
A case whose result is **absent** reads as **"not run"** and fails the report —
|
|
144
|
+
an unverified threat is never silently green. Run it against Foundry:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pnpm redteam # builds the package, runs forge, prints the report + threat map
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The script (`packages/conformance/scripts/redteam-report.mjs`) shells out to
|
|
151
|
+
`forge test --match-path 'test/redteam/*' --json`, parses the nested result
|
|
152
|
+
shape, and renders a normal `formatReport` (exit code `0` only if every case was
|
|
153
|
+
Foundry-verified). `--input <file>` parses a saved JSON instead, and
|
|
154
|
+
`--contracts-dir <path>` overrides the checkout location.
|
|
155
|
+
|
|
156
|
+
## Writing a suite
|
|
157
|
+
|
|
158
|
+
A check returns a short pass message or throws to fail. ERC-7579 checks narrow the
|
|
159
|
+
target with `accountTarget`; other suites read their own bound port:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { accountTarget, type Check } from '@keelcodes/conformance';
|
|
163
|
+
|
|
164
|
+
const myCheck: Check = {
|
|
165
|
+
id: 'ercXXXX.thing.holds',
|
|
166
|
+
title: 'Thing holds',
|
|
167
|
+
spec: 'ERC-XXXX §1.2',
|
|
168
|
+
severity: 'high',
|
|
169
|
+
async run(target) {
|
|
170
|
+
const { reader, account } = accountTarget(target);
|
|
171
|
+
if (!(await reader.hasCode(account))) throw new Error('not deployed');
|
|
172
|
+
return 'ok';
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`runChecks` / `runSuite` never throw: a throwing check is recorded as a failure
|
|
178
|
+
with its message, so one broken probe cannot abort a run.
|
|
179
|
+
|
|
180
|
+
## Develop
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
pnpm --filter @keelcodes/conformance test
|
|
184
|
+
pnpm --filter @keelcodes/conformance typecheck
|
|
185
|
+
pnpm redteam # Foundry red-team cases → conformance report (needs forge)
|
|
186
|
+
pnpm sandbox # docker compose -f infra/docker-compose.yml up
|
|
187
|
+
```
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERC-7579 account views a conformance run needs. Kept local to this package —
|
|
3
|
+
* the suite probes the standard surface, not any project's adapter ABI.
|
|
4
|
+
*/
|
|
5
|
+
export declare const erc7579AccountAbi: readonly [{
|
|
6
|
+
readonly name: "isModuleInstalled";
|
|
7
|
+
readonly type: "function";
|
|
8
|
+
readonly stateMutability: "view";
|
|
9
|
+
readonly inputs: readonly [{
|
|
10
|
+
readonly type: "uint256";
|
|
11
|
+
readonly name: "moduleTypeId";
|
|
12
|
+
}, {
|
|
13
|
+
readonly type: "address";
|
|
14
|
+
readonly name: "module";
|
|
15
|
+
}, {
|
|
16
|
+
readonly type: "bytes";
|
|
17
|
+
readonly name: "additionalContext";
|
|
18
|
+
}];
|
|
19
|
+
readonly outputs: readonly [{
|
|
20
|
+
readonly type: "bool";
|
|
21
|
+
}];
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "supportsExecutionMode";
|
|
24
|
+
readonly type: "function";
|
|
25
|
+
readonly stateMutability: "view";
|
|
26
|
+
readonly inputs: readonly [{
|
|
27
|
+
readonly type: "bytes32";
|
|
28
|
+
readonly name: "mode";
|
|
29
|
+
}];
|
|
30
|
+
readonly outputs: readonly [{
|
|
31
|
+
readonly type: "bool";
|
|
32
|
+
}];
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "accountId";
|
|
35
|
+
readonly type: "function";
|
|
36
|
+
readonly stateMutability: "view";
|
|
37
|
+
readonly inputs: readonly [];
|
|
38
|
+
readonly outputs: readonly [{
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
}];
|
|
41
|
+
}];
|
|
42
|
+
/** ERC-7579 `IModule` views, read from the module itself. */
|
|
43
|
+
export declare const erc7579ModuleAbi: readonly [{
|
|
44
|
+
readonly name: "isInitialized";
|
|
45
|
+
readonly type: "function";
|
|
46
|
+
readonly stateMutability: "view";
|
|
47
|
+
readonly inputs: readonly [{
|
|
48
|
+
readonly type: "address";
|
|
49
|
+
readonly name: "smartAccount";
|
|
50
|
+
}];
|
|
51
|
+
readonly outputs: readonly [{
|
|
52
|
+
readonly type: "bool";
|
|
53
|
+
}];
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "isModuleType";
|
|
56
|
+
readonly type: "function";
|
|
57
|
+
readonly stateMutability: "view";
|
|
58
|
+
readonly inputs: readonly [{
|
|
59
|
+
readonly type: "uint256";
|
|
60
|
+
readonly name: "moduleTypeId";
|
|
61
|
+
}];
|
|
62
|
+
readonly outputs: readonly [{
|
|
63
|
+
readonly type: "bool";
|
|
64
|
+
}];
|
|
65
|
+
}];
|
|
66
|
+
/**
|
|
67
|
+
* ERC-7710 delegation-manager views. The EIP fixes only `redeemDelegations`; the
|
|
68
|
+
* getters below are the MetaMask delegation-framework reference that the EIP
|
|
69
|
+
* names, which is what a conformance run can actually probe.
|
|
70
|
+
*/
|
|
71
|
+
export declare const erc7710ManagerAbi: readonly [{
|
|
72
|
+
readonly name: "getDomainHash";
|
|
73
|
+
readonly type: "function";
|
|
74
|
+
readonly stateMutability: "view";
|
|
75
|
+
readonly inputs: readonly [];
|
|
76
|
+
readonly outputs: readonly [{
|
|
77
|
+
readonly type: "bytes32";
|
|
78
|
+
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "getDelegationHash";
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
readonly inputs: readonly [{
|
|
84
|
+
readonly type: "tuple";
|
|
85
|
+
readonly components: readonly [{
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
readonly name: "delegate";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "address";
|
|
90
|
+
readonly name: "delegator";
|
|
91
|
+
}, {
|
|
92
|
+
readonly type: "bytes32";
|
|
93
|
+
readonly name: "authority";
|
|
94
|
+
}, {
|
|
95
|
+
readonly type: "tuple[]";
|
|
96
|
+
readonly components: readonly [{
|
|
97
|
+
readonly type: "address";
|
|
98
|
+
readonly name: "enforcer";
|
|
99
|
+
}, {
|
|
100
|
+
readonly type: "bytes";
|
|
101
|
+
readonly name: "terms";
|
|
102
|
+
}, {
|
|
103
|
+
readonly type: "bytes";
|
|
104
|
+
readonly name: "args";
|
|
105
|
+
}];
|
|
106
|
+
readonly name: "caveats";
|
|
107
|
+
}, {
|
|
108
|
+
readonly type: "uint256";
|
|
109
|
+
readonly name: "salt";
|
|
110
|
+
}, {
|
|
111
|
+
readonly type: "bytes";
|
|
112
|
+
readonly name: "signature";
|
|
113
|
+
}];
|
|
114
|
+
readonly name: "delegation";
|
|
115
|
+
}];
|
|
116
|
+
readonly outputs: readonly [{
|
|
117
|
+
readonly type: "bytes32";
|
|
118
|
+
}];
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "disabledDelegations";
|
|
121
|
+
readonly type: "function";
|
|
122
|
+
readonly stateMutability: "view";
|
|
123
|
+
readonly inputs: readonly [{
|
|
124
|
+
readonly type: "bytes32";
|
|
125
|
+
readonly name: "delegationHash";
|
|
126
|
+
}];
|
|
127
|
+
readonly outputs: readonly [{
|
|
128
|
+
readonly type: "bool";
|
|
129
|
+
}];
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "ROOT_AUTHORITY";
|
|
132
|
+
readonly type: "function";
|
|
133
|
+
readonly stateMutability: "view";
|
|
134
|
+
readonly inputs: readonly [];
|
|
135
|
+
readonly outputs: readonly [{
|
|
136
|
+
readonly type: "bytes32";
|
|
137
|
+
}];
|
|
138
|
+
}, {
|
|
139
|
+
readonly name: "ANY_DELEGATE";
|
|
140
|
+
readonly type: "function";
|
|
141
|
+
readonly stateMutability: "view";
|
|
142
|
+
readonly inputs: readonly [];
|
|
143
|
+
readonly outputs: readonly [{
|
|
144
|
+
readonly type: "address";
|
|
145
|
+
}];
|
|
146
|
+
}, {
|
|
147
|
+
readonly name: "NAME";
|
|
148
|
+
readonly type: "function";
|
|
149
|
+
readonly stateMutability: "view";
|
|
150
|
+
readonly inputs: readonly [];
|
|
151
|
+
readonly outputs: readonly [{
|
|
152
|
+
readonly type: "string";
|
|
153
|
+
}];
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "VERSION";
|
|
156
|
+
readonly type: "function";
|
|
157
|
+
readonly stateMutability: "view";
|
|
158
|
+
readonly inputs: readonly [];
|
|
159
|
+
readonly outputs: readonly [{
|
|
160
|
+
readonly type: "string";
|
|
161
|
+
}];
|
|
162
|
+
}];
|
|
163
|
+
/** ERC-8004 identity registry — ERC-721 with agent extensions. */
|
|
164
|
+
export declare const erc8004IdentityAbi: readonly [{
|
|
165
|
+
readonly name: "ownerOf";
|
|
166
|
+
readonly type: "function";
|
|
167
|
+
readonly stateMutability: "view";
|
|
168
|
+
readonly inputs: readonly [{
|
|
169
|
+
readonly type: "uint256";
|
|
170
|
+
readonly name: "agentId";
|
|
171
|
+
}];
|
|
172
|
+
readonly outputs: readonly [{
|
|
173
|
+
readonly type: "address";
|
|
174
|
+
}];
|
|
175
|
+
}, {
|
|
176
|
+
readonly name: "tokenURI";
|
|
177
|
+
readonly type: "function";
|
|
178
|
+
readonly stateMutability: "view";
|
|
179
|
+
readonly inputs: readonly [{
|
|
180
|
+
readonly type: "uint256";
|
|
181
|
+
readonly name: "agentId";
|
|
182
|
+
}];
|
|
183
|
+
readonly outputs: readonly [{
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
}];
|
|
186
|
+
}, {
|
|
187
|
+
readonly name: "getAgentWallet";
|
|
188
|
+
readonly type: "function";
|
|
189
|
+
readonly stateMutability: "view";
|
|
190
|
+
readonly inputs: readonly [{
|
|
191
|
+
readonly type: "uint256";
|
|
192
|
+
readonly name: "agentId";
|
|
193
|
+
}];
|
|
194
|
+
readonly outputs: readonly [{
|
|
195
|
+
readonly type: "address";
|
|
196
|
+
}];
|
|
197
|
+
}, {
|
|
198
|
+
readonly name: "supportsInterface";
|
|
199
|
+
readonly type: "function";
|
|
200
|
+
readonly stateMutability: "view";
|
|
201
|
+
readonly inputs: readonly [{
|
|
202
|
+
readonly type: "bytes4";
|
|
203
|
+
readonly name: "interfaceId";
|
|
204
|
+
}];
|
|
205
|
+
readonly outputs: readonly [{
|
|
206
|
+
readonly type: "bool";
|
|
207
|
+
}];
|
|
208
|
+
}];
|
|
209
|
+
/** ERC-8004 reputation registry — the binding to its identity registry. */
|
|
210
|
+
export declare const erc8004ReputationAbi: readonly [{
|
|
211
|
+
readonly name: "getIdentityRegistry";
|
|
212
|
+
readonly type: "function";
|
|
213
|
+
readonly stateMutability: "view";
|
|
214
|
+
readonly inputs: readonly [];
|
|
215
|
+
readonly outputs: readonly [{
|
|
216
|
+
readonly type: "address";
|
|
217
|
+
}];
|
|
218
|
+
}];
|
|
219
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI5B,CAAC;AAEH,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;EAG3B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ5B,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK7B,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB;;;;;;;;EAE/B,CAAC"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseAbi } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* ERC-7579 account views a conformance run needs. Kept local to this package —
|
|
4
|
+
* the suite probes the standard surface, not any project's adapter ABI.
|
|
5
|
+
*/
|
|
6
|
+
export const erc7579AccountAbi = parseAbi([
|
|
7
|
+
'function isModuleInstalled(uint256 moduleTypeId, address module, bytes additionalContext) view returns (bool)',
|
|
8
|
+
'function supportsExecutionMode(bytes32 mode) view returns (bool)',
|
|
9
|
+
'function accountId() view returns (string)',
|
|
10
|
+
]);
|
|
11
|
+
/** ERC-7579 `IModule` views, read from the module itself. */
|
|
12
|
+
export const erc7579ModuleAbi = parseAbi([
|
|
13
|
+
'function isInitialized(address smartAccount) view returns (bool)',
|
|
14
|
+
'function isModuleType(uint256 moduleTypeId) view returns (bool)',
|
|
15
|
+
]);
|
|
16
|
+
/**
|
|
17
|
+
* ERC-7710 delegation-manager views. The EIP fixes only `redeemDelegations`; the
|
|
18
|
+
* getters below are the MetaMask delegation-framework reference that the EIP
|
|
19
|
+
* names, which is what a conformance run can actually probe.
|
|
20
|
+
*/
|
|
21
|
+
export const erc7710ManagerAbi = parseAbi([
|
|
22
|
+
'function getDomainHash() view returns (bytes32)',
|
|
23
|
+
'function getDelegationHash((address delegate, address delegator, bytes32 authority, (address enforcer, bytes terms, bytes args)[] caveats, uint256 salt, bytes signature) delegation) view returns (bytes32)',
|
|
24
|
+
'function disabledDelegations(bytes32 delegationHash) view returns (bool)',
|
|
25
|
+
'function ROOT_AUTHORITY() view returns (bytes32)',
|
|
26
|
+
'function ANY_DELEGATE() view returns (address)',
|
|
27
|
+
'function NAME() view returns (string)',
|
|
28
|
+
'function VERSION() view returns (string)',
|
|
29
|
+
]);
|
|
30
|
+
/** ERC-8004 identity registry — ERC-721 with agent extensions. */
|
|
31
|
+
export const erc8004IdentityAbi = parseAbi([
|
|
32
|
+
'function ownerOf(uint256 agentId) view returns (address)',
|
|
33
|
+
'function tokenURI(uint256 agentId) view returns (string)',
|
|
34
|
+
'function getAgentWallet(uint256 agentId) view returns (address)',
|
|
35
|
+
'function supportsInterface(bytes4 interfaceId) view returns (bool)',
|
|
36
|
+
]);
|
|
37
|
+
/** ERC-8004 reputation registry — the binding to its identity registry. */
|
|
38
|
+
export const erc8004ReputationAbi = parseAbi([
|
|
39
|
+
'function getIdentityRegistry() view returns (address)',
|
|
40
|
+
]);
|
|
41
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACxC,+GAA+G;IAC/G,kEAAkE;IAClE,4CAA4C;CAC7C,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,kEAAkE;IAClE,iEAAiE;CAClE,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACxC,iDAAiD;IACjD,8MAA8M;IAC9M,0EAA0E;IAC1E,kDAAkD;IAClD,gDAAgD;IAChD,uCAAuC;IACvC,0CAA0C;CAC3C,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACzC,0DAA0D;IAC1D,0DAA0D;IAC1D,iEAAiE;IACjE,oEAAoE;CACrE,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC3C,uDAAuD;CACxD,CAAC,CAAC"}
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PublicClient } from 'viem';
|
|
2
|
+
import type { Address, AgentRegistryReader, Check, Hex, Suite } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* ERC-8004 conformance (Trustless Agents).
|
|
5
|
+
*
|
|
6
|
+
* The identity registry is an ERC-721 whose `tokenId` is the `agentId`, with
|
|
7
|
+
* agent-specific extensions (`getAgentWallet`, `agentURI`). The suite checks the
|
|
8
|
+
* registry is a real ERC-721 and that the agent under test is registered with a
|
|
9
|
+
* resolvable owner, URI and wallet; optionally that a reputation registry is
|
|
10
|
+
* bound to the same identity registry.
|
|
11
|
+
*/
|
|
12
|
+
/** `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`-style id for ERC-721. */
|
|
13
|
+
export declare const ERC721_INTERFACE_ID: Hex;
|
|
14
|
+
export declare const ERC8004_CHECKS: readonly Check[];
|
|
15
|
+
/** ERC-8004 agent registry suite. */
|
|
16
|
+
export declare const ERC8004_SUITE: Suite;
|
|
17
|
+
export interface ViemAgentRegistryOptions {
|
|
18
|
+
identityRegistry: Address;
|
|
19
|
+
agentId: bigint;
|
|
20
|
+
reputationRegistry?: Address;
|
|
21
|
+
}
|
|
22
|
+
/** Points the ERC-8004 suite at live registries via a viem client. */
|
|
23
|
+
export declare function createViemAgentRegistryReader(client: PublicClient, options: ViemAgentRegistryOptions): AgentRegistryReader;
|
|
24
|
+
//# sourceMappingURL=agents.d.ts.map
|