sigild 0.0.1
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/CONTRIBUTING.md +39 -0
- package/LICENSE +202 -0
- package/README.md +70 -0
- package/THREAT_MODEL.md +84 -0
- package/dist/src/audit/index.d.ts +2 -0
- package/dist/src/audit/index.d.ts.map +1 -0
- package/dist/src/audit/index.js +2 -0
- package/dist/src/audit/index.js.map +1 -0
- package/dist/src/audit/log.d.ts +96 -0
- package/dist/src/audit/log.d.ts.map +1 -0
- package/dist/src/audit/log.js +229 -0
- package/dist/src/audit/log.js.map +1 -0
- package/dist/src/bin/sigild.d.ts +3 -0
- package/dist/src/bin/sigild.d.ts.map +1 -0
- package/dist/src/bin/sigild.js +30 -0
- package/dist/src/bin/sigild.js.map +1 -0
- package/dist/src/crypto/aead.d.ts +9 -0
- package/dist/src/crypto/aead.d.ts.map +1 -0
- package/dist/src/crypto/aead.js +38 -0
- package/dist/src/crypto/aead.js.map +1 -0
- package/dist/src/crypto/index.d.ts +5 -0
- package/dist/src/crypto/index.d.ts.map +1 -0
- package/dist/src/crypto/index.js +5 -0
- package/dist/src/crypto/index.js.map +1 -0
- package/dist/src/crypto/kdf.d.ts +10 -0
- package/dist/src/crypto/kdf.d.ts.map +1 -0
- package/dist/src/crypto/kdf.js +27 -0
- package/dist/src/crypto/kdf.js.map +1 -0
- package/dist/src/crypto/keyfile.d.ts +12 -0
- package/dist/src/crypto/keyfile.d.ts.map +1 -0
- package/dist/src/crypto/keyfile.js +114 -0
- package/dist/src/crypto/keyfile.js.map +1 -0
- package/dist/src/crypto/secret-buffer.d.ts +19 -0
- package/dist/src/crypto/secret-buffer.d.ts.map +1 -0
- package/dist/src/crypto/secret-buffer.js +48 -0
- package/dist/src/crypto/secret-buffer.js.map +1 -0
- package/dist/src/daemon/handles.d.ts +51 -0
- package/dist/src/daemon/handles.d.ts.map +1 -0
- package/dist/src/daemon/handles.js +140 -0
- package/dist/src/daemon/handles.js.map +1 -0
- package/dist/src/daemon/index.d.ts +5 -0
- package/dist/src/daemon/index.d.ts.map +1 -0
- package/dist/src/daemon/index.js +5 -0
- package/dist/src/daemon/index.js.map +1 -0
- package/dist/src/daemon/methods.d.ts +20 -0
- package/dist/src/daemon/methods.d.ts.map +1 -0
- package/dist/src/daemon/methods.js +221 -0
- package/dist/src/daemon/methods.js.map +1 -0
- package/dist/src/daemon/passphrase.d.ts +14 -0
- package/dist/src/daemon/passphrase.d.ts.map +1 -0
- package/dist/src/daemon/passphrase.js +49 -0
- package/dist/src/daemon/passphrase.js.map +1 -0
- package/dist/src/daemon/rpc.d.ts +61 -0
- package/dist/src/daemon/rpc.d.ts.map +1 -0
- package/dist/src/daemon/rpc.js +76 -0
- package/dist/src/daemon/rpc.js.map +1 -0
- package/dist/src/daemon/runtime.d.ts +40 -0
- package/dist/src/daemon/runtime.d.ts.map +1 -0
- package/dist/src/daemon/runtime.js +61 -0
- package/dist/src/daemon/runtime.js.map +1 -0
- package/dist/src/daemon/server.d.ts +53 -0
- package/dist/src/daemon/server.d.ts.map +1 -0
- package/dist/src/daemon/server.js +103 -0
- package/dist/src/daemon/server.js.map +1 -0
- package/dist/src/eth/address.d.ts +13 -0
- package/dist/src/eth/address.d.ts.map +1 -0
- package/dist/src/eth/address.js +51 -0
- package/dist/src/eth/address.js.map +1 -0
- package/dist/src/eth/index.d.ts +8 -0
- package/dist/src/eth/index.d.ts.map +1 -0
- package/dist/src/eth/index.js +8 -0
- package/dist/src/eth/index.js.map +1 -0
- package/dist/src/eth/keccak.d.ts +2 -0
- package/dist/src/eth/keccak.d.ts.map +1 -0
- package/dist/src/eth/keccak.js +5 -0
- package/dist/src/eth/keccak.js.map +1 -0
- package/dist/src/eth/rlp.d.ts +16 -0
- package/dist/src/eth/rlp.d.ts.map +1 -0
- package/dist/src/eth/rlp.js +99 -0
- package/dist/src/eth/rlp.js.map +1 -0
- package/dist/src/eth/secp.d.ts +17 -0
- package/dist/src/eth/secp.d.ts.map +1 -0
- package/dist/src/eth/secp.js +43 -0
- package/dist/src/eth/secp.js.map +1 -0
- package/dist/src/eth/sign-message.d.ts +18 -0
- package/dist/src/eth/sign-message.d.ts.map +1 -0
- package/dist/src/eth/sign-message.js +42 -0
- package/dist/src/eth/sign-message.js.map +1 -0
- package/dist/src/eth/sign-tx.d.ts +38 -0
- package/dist/src/eth/sign-tx.d.ts.map +1 -0
- package/dist/src/eth/sign-tx.js +92 -0
- package/dist/src/eth/sign-tx.js.map +1 -0
- package/dist/src/eth/sign-typed.d.ts +33 -0
- package/dist/src/eth/sign-typed.d.ts.map +1 -0
- package/dist/src/eth/sign-typed.js +142 -0
- package/dist/src/eth/sign-typed.js.map +1 -0
- package/package.json +59 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributing to sigil
|
|
2
|
+
|
|
3
|
+
## Workflow
|
|
4
|
+
|
|
5
|
+
- Work happens on feature branches: `feat/<layer>`, `fix/<short>`, or `chore/<short>`.
|
|
6
|
+
- Push the branch and open a PR against `main`.
|
|
7
|
+
- PR description links the issue with a `Refs #N` or `Closes #N` trailer.
|
|
8
|
+
- CI must pass before merge. The required check is `Test (Node 22)`.
|
|
9
|
+
- Squash-merge only (linear history on `main`).
|
|
10
|
+
- Delete the branch after merge.
|
|
11
|
+
|
|
12
|
+
Direct pushes to `main` are blocked by branch protection. Repo admins can bypass in an emergency, but should still prefer the PR path.
|
|
13
|
+
|
|
14
|
+
## Local development
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install # respects .npmrc (ignore-scripts=true)
|
|
18
|
+
npm test # tsc + node --test 'dist/test/**/*.test.js'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Tests must pass locally before pushing.
|
|
22
|
+
|
|
23
|
+
## Commit messages
|
|
24
|
+
|
|
25
|
+
- Subject line under 70 characters, imperative mood ("Add X", not "Added X").
|
|
26
|
+
- Body explains the **why**. The diff already shows the **what**.
|
|
27
|
+
- No `Co-Authored-By` trailers.
|
|
28
|
+
- Reference issues with `Refs #N` (partial work) or `Closes #N` (completes the issue).
|
|
29
|
+
|
|
30
|
+
## Security
|
|
31
|
+
|
|
32
|
+
Never commit:
|
|
33
|
+
- `.env`, `.env.*`
|
|
34
|
+
- `*.pem`, `*.key`, `*.keystore`
|
|
35
|
+
- Anything inside `~/.sigil/` or a project-local `.sigil/`
|
|
36
|
+
|
|
37
|
+
The repo `.gitignore` covers these patterns. Double-check `git status` before committing.
|
|
38
|
+
|
|
39
|
+
For security issues in sigil itself, open a private GitHub Security Advisory rather than a public issue.
|
package/LICENSE
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# sigil
|
|
2
|
+
|
|
3
|
+
> Claude can sign, but never see.
|
|
4
|
+
|
|
5
|
+
`sigil` is a local signing daemon and Claude Code integration that lets agentic coding tools use private keys without ever putting key material in the model's context window.
|
|
6
|
+
|
|
7
|
+
**Status:** pre-alpha. Threat model is committed before the code. Do not use this with real funds yet. Build plan and current progress live in the [tracking issue](https://github.com/cdrn/sigil/issues/9).
|
|
8
|
+
|
|
9
|
+
## What it is
|
|
10
|
+
|
|
11
|
+
Three components that work together:
|
|
12
|
+
|
|
13
|
+
1. **`sigild`** — a long-running local daemon that holds unlocked keys in process memory (zeroized on shutdown; mlock against swap is planned, see [THREAT_MODEL.md](./THREAT_MODEL.md)) and exposes signing operations over a Unix socket. Keys at rest are encrypted with XChaCha20-Poly1305 and an Argon2id-derived key.
|
|
14
|
+
2. **`sigil-mcp`** — an MCP server that Claude (or any agentic tool) talks to. It forwards signing requests to `sigild` and returns signatures. Claude never sees key material — only opaque handles like `eth:executor`.
|
|
15
|
+
3. **Hooks (the wards)** — `sigil init` installs PreToolUse and PostToolUse hooks into `.claude/settings.json` that block `Read` and `Bash` from touching key paths, and redact key-shaped strings from tool output.
|
|
16
|
+
|
|
17
|
+
## What it isn't
|
|
18
|
+
|
|
19
|
+
- Not a hardware wallet replacement. If you can use a Ledger or YubiKey, do that.
|
|
20
|
+
- Not a custody solution. It runs on your laptop or VPS and protects you from one specific class of failure: leaking key material through an LLM agent.
|
|
21
|
+
- Not a substitute for policy. The library prevents *ingestion* of keys; the policy engine prevents *misuse* of signing authority. Both matter — see the threat model.
|
|
22
|
+
|
|
23
|
+
## How it will work (sketch)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# one-time setup
|
|
27
|
+
sigil init # installs hooks into ~/.claude/settings.json
|
|
28
|
+
sigil up # starts the daemon, unlocks keys via OS keychain
|
|
29
|
+
|
|
30
|
+
# register a key with policy
|
|
31
|
+
sigil portal add executor \
|
|
32
|
+
--type eth \
|
|
33
|
+
--key-file ~/keys/bot.key \
|
|
34
|
+
--policy ./policies/executor.toml
|
|
35
|
+
|
|
36
|
+
# Claude now sees `eth:executor` as a portal it can sign with,
|
|
37
|
+
# but cannot read the key file or anything under ~/.sigil
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A policy file looks like:
|
|
41
|
+
|
|
42
|
+
```toml
|
|
43
|
+
[portal.executor]
|
|
44
|
+
chain_ids = [1, 42161, 8453]
|
|
45
|
+
allow_to = ["0xRouter...", "0xExecutor..."]
|
|
46
|
+
max_value_wei = "100000000000000000" # 0.1 ETH per tx
|
|
47
|
+
max_value_per_hour_wei = "500000000000000000"
|
|
48
|
+
allowed_selectors = ["0xa9059cbb", "0x095ea7b3"] # transfer, approve
|
|
49
|
+
require_confirm_above_wei = "10000000000000000" # push to phone for human ack
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Supply chain posture
|
|
53
|
+
|
|
54
|
+
Key-management libraries die from supply chain compromise, not from clever attacks on the code. Given the npm ecosystem in 2026 (Mini Shai-Hulud, Axios, pgserve, TanStack), `sigil` commits to:
|
|
55
|
+
|
|
56
|
+
- **Zero install scripts.** No `postinstall`, `preinstall`, `prepare`. CI-enforced.
|
|
57
|
+
- **Minimal dependencies.** Core sign path uses [`@noble/secp256k1`](https://github.com/paulmillr/noble-secp256k1) and `@noble/hashes` (audited, zero-dep). No viem in the core daemon.
|
|
58
|
+
- **No Bun.** Plain Node only. Bun is currently being weaponized by Mini Shai-Hulud as an evasion layer; we will not give that pattern any cover.
|
|
59
|
+
- **Provenance attestations** on every npm release via GitHub Actions trusted publishing.
|
|
60
|
+
- **Signed standalone binaries** from GitHub Releases for users who'd rather not touch npm.
|
|
61
|
+
- **Reproducible builds + SBOM** published with each release.
|
|
62
|
+
- **No long-lived publish tokens.** OIDC only.
|
|
63
|
+
|
|
64
|
+
## Threat model
|
|
65
|
+
|
|
66
|
+
See [THREAT_MODEL.md](./THREAT_MODEL.md). Read it before trusting this with anything.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Apache License 2.0. See [LICENSE](./LICENSE).
|
package/THREAT_MODEL.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Threat Model
|
|
2
|
+
|
|
3
|
+
This document describes what `sigil` defends against, what it doesn't, and the assumptions it makes. Read it before deciding whether `sigil` is appropriate for your use case.
|
|
4
|
+
|
|
5
|
+
## Actors
|
|
6
|
+
|
|
7
|
+
- **The user.** Has root on the machine. Trusted.
|
|
8
|
+
- **The agent (e.g. Claude).** Untrusted in the specific sense that its context window can be poisoned by adversarial inputs (prompt injection from web pages, file contents, tool output). The agent itself is not malicious, but anything it ingests can become an instruction.
|
|
9
|
+
- **The attacker.** May control content the agent reads (web pages, repos, API responses, transaction calldata) and may have published malicious dependencies the user installs.
|
|
10
|
+
- **The host OS.** Trusted. If the attacker has local code execution as your user, `sigil` does not help.
|
|
11
|
+
|
|
12
|
+
## Assets
|
|
13
|
+
|
|
14
|
+
In order of value:
|
|
15
|
+
|
|
16
|
+
1. **Private key material.** Must never leave `sigild`'s address space.
|
|
17
|
+
2. **Signing authority.** A signature `sigild` produces on behalf of a portal is a financial action. The set of authorized actions is bounded by per-portal policy.
|
|
18
|
+
3. **The audit log.** Append-only record of every sign decision. Tampering with it defeats post-incident forensics.
|
|
19
|
+
|
|
20
|
+
## In scope
|
|
21
|
+
|
|
22
|
+
### 1. Preventing key ingestion by the agent
|
|
23
|
+
|
|
24
|
+
The primary threat. Failure mode: a private key ends up in the agent's context window, then in transcripts, prompt caches, cloud logs, or attacker-controlled exfiltration paths.
|
|
25
|
+
|
|
26
|
+
Defenses:
|
|
27
|
+
- Keys live in `sigild`'s memory only, unlocked from encrypted at-rest storage. Plaintext is zeroized on shutdown. mlock against swap is planned (requires a native module distributed as bundled prebuilds, see Known limitations).
|
|
28
|
+
- The MCP interface exposes only opaque handles (`eth:executor`), never key bytes.
|
|
29
|
+
- PreToolUse hooks block `Read` and `Bash` access to `~/.sigil/**`, `*.pem`, `**/.env*`, `**/keystore*`, and a configurable extra list.
|
|
30
|
+
- PostToolUse output filter redacts hex-encoded 32-byte blobs, PEM blocks, and bip39-shaped strings from tool output before it reaches the model.
|
|
31
|
+
|
|
32
|
+
### 2. Bounding signing authority
|
|
33
|
+
|
|
34
|
+
A defended key still loses you money if the agent can be tricked into signing the wrong payload. Prompt injection through transaction calldata, web content, or repo files can redirect signing intent.
|
|
35
|
+
|
|
36
|
+
Defenses (policy engine, per portal):
|
|
37
|
+
- Destination allowlists (`allow_to`)
|
|
38
|
+
- Per-tx and rolling-window value caps
|
|
39
|
+
- Allowed function selectors (only `transfer`, `approve`, etc.)
|
|
40
|
+
- Chain ID allowlists
|
|
41
|
+
- Out-of-band human confirmation above a configurable value threshold (push to Pushover / Telegram / Apple Push)
|
|
42
|
+
- Append-only audit log with monotonic counter
|
|
43
|
+
|
|
44
|
+
### 3. Supply chain compromise of `sigil` itself
|
|
45
|
+
|
|
46
|
+
Given the 2026 npm threat landscape, a compromised release of `sigil` would be catastrophic. Defenses:
|
|
47
|
+
|
|
48
|
+
- Zero install scripts (`postinstall`, `preinstall`, `prepare`). CI-enforced.
|
|
49
|
+
- Minimal, audited dependencies (`@noble/*` family, plain Node stdlib).
|
|
50
|
+
- Provenance attestations via GitHub Actions trusted publishing (OIDC, no long-lived tokens).
|
|
51
|
+
- Signed standalone binaries as an alternative distribution channel.
|
|
52
|
+
- Reproducible builds, published SBOM, public release checksums.
|
|
53
|
+
- No Bun in any distributed artifact.
|
|
54
|
+
|
|
55
|
+
## Out of scope
|
|
56
|
+
|
|
57
|
+
`sigil` does not defend against:
|
|
58
|
+
|
|
59
|
+
- **Local code execution as your user.** If an attacker can run code as `$USER`, they can `ptrace` the daemon, read mlock'd memory, or simply ask `sigild` to sign things over the socket. `sigil` makes this harder (audit log will show it, policy still applies) but does not prevent it.
|
|
60
|
+
- **Root or kernel compromise.** mlock prevents swap; it does not prevent a root user from reading process memory.
|
|
61
|
+
- **Side channels on shared hardware.** Cache timing, Rowhammer, etc.
|
|
62
|
+
- **Physical access to an unlocked machine.**
|
|
63
|
+
- **Malicious user.** If you're trying to protect keys from yourself, you want a hardware wallet, not `sigil`.
|
|
64
|
+
- **Compromise of upstream cryptographic primitives.** We rely on `@noble/*` being correct. If secp256k1 is broken, everyone has bigger problems.
|
|
65
|
+
- **Confused-deputy at the policy boundary.** If your policy says "any tx to 0xRouter is fine" and the router happens to forward arbitrary calldata, `sigil` will sign whatever the agent asks. Policies must be written defensively.
|
|
66
|
+
|
|
67
|
+
## Assumptions
|
|
68
|
+
|
|
69
|
+
- The user installs `sigil` through a trusted channel (signed release, verified npm provenance, or built from source).
|
|
70
|
+
- The host OS enforces standard process isolation.
|
|
71
|
+
- The user's OS keychain (or chosen unlock mechanism) is not compromised.
|
|
72
|
+
- Clock skew on the host is bounded (matters for rolling-window policy and audit timestamps).
|
|
73
|
+
|
|
74
|
+
## Known limitations
|
|
75
|
+
|
|
76
|
+
- The hook-based path blocker is best-effort: it covers `Read` and `Bash`, but a sufficiently creative agent could still ask another tool to do the read. The defense in depth is that even if a key file is read, its contents are redacted by the output filter before reaching the model.
|
|
77
|
+
- The output redaction filter has false negatives (keys with non-standard encoding) and false positives (legitimate hex blobs). It is not a replacement for the path blocker; it's a second line.
|
|
78
|
+
- The MCP socket is currently unauthenticated within the user's session. Any process running as `$USER` can connect to it. This is consistent with the threat model (we don't defend against local user compromise) but worth stating explicitly.
|
|
79
|
+
- **mlock is not yet implemented.** Plaintext key material lives in a regular `Buffer` that is zeroized on daemon shutdown or unlock-failure. This means keys are vulnerable to being paged to swap on a memory-pressured system. mlock requires a native module, which we will ship as bundled prebuilds (no install scripts) rather than via a compile-on-install dependency. Tracked as a planned layer.
|
|
80
|
+
- Out-of-band confirmation depends on a working push channel. If the push provider is down, high-value signs are denied, not approved.
|
|
81
|
+
|
|
82
|
+
## Reporting issues
|
|
83
|
+
|
|
84
|
+
Security issues: open a GitHub security advisory on the repo. Please do not file public issues for vulnerabilities.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type AuditDecision, type AuditEntry, type StoredAuditEntry, type ChainHead, ZERO_HASH, HASH_HEX_LEN, AuditChainError, AuditWriter, canonicalJSON, hashEntry, sealEntry, serializeEntry, parseLine, verifyChain, readHead, } from './log.js';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/audit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export type AuditDecision = 'allow' | 'deny' | 'confirm_required';
|
|
2
|
+
export interface AuditEntry {
|
|
3
|
+
seq: number;
|
|
4
|
+
ts: number;
|
|
5
|
+
prev_hash: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
portal: string;
|
|
8
|
+
payload: unknown;
|
|
9
|
+
decision: AuditDecision;
|
|
10
|
+
reason?: string;
|
|
11
|
+
sig?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface StoredAuditEntry extends AuditEntry {
|
|
14
|
+
hash: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const ZERO_HASH: string;
|
|
17
|
+
export declare const HASH_HEX_LEN = 64;
|
|
18
|
+
export declare class AuditChainError extends Error {
|
|
19
|
+
readonly atSeq: number | undefined;
|
|
20
|
+
constructor(msg: string, atSeq?: number);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Canonical JSON serialization: keys sorted lexicographically, recursive.
|
|
24
|
+
* This is what we hash, so it must be deterministic across engine
|
|
25
|
+
* versions and across re-serializations.
|
|
26
|
+
*/
|
|
27
|
+
export declare function canonicalJSON(value: unknown): string;
|
|
28
|
+
/**
|
|
29
|
+
* Compute the keccak256 hash of an entry (without the `hash` field).
|
|
30
|
+
* Returns lowercase hex.
|
|
31
|
+
*/
|
|
32
|
+
export declare function hashEntry(entry: AuditEntry): string;
|
|
33
|
+
/**
|
|
34
|
+
* Stamp an entry with its hash.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sealEntry(entry: AuditEntry): StoredAuditEntry;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a stored entry to a single JSON line (newline-terminated).
|
|
39
|
+
*/
|
|
40
|
+
export declare function serializeEntry(entry: StoredAuditEntry): string;
|
|
41
|
+
/**
|
|
42
|
+
* Parse a single line and verify its self-hash. Does NOT check chain linkage.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseLine(line: string): StoredAuditEntry;
|
|
45
|
+
/**
|
|
46
|
+
* Verify a buffer's worth of JSONL audit entries.
|
|
47
|
+
* - Empty buffer → empty chain.
|
|
48
|
+
* - Each entry must self-hash correctly.
|
|
49
|
+
* - Each entry's seq must be expected (0, 1, 2, ...).
|
|
50
|
+
* - Each entry's prev_hash must match the previous entry's hash.
|
|
51
|
+
* - A trailing non-empty fragment (no terminating newline) is a torn write.
|
|
52
|
+
*
|
|
53
|
+
* Returns the entries in order. Throws AuditChainError on any failure.
|
|
54
|
+
*/
|
|
55
|
+
export declare function verifyChain(buf: Buffer | string): StoredAuditEntry[];
|
|
56
|
+
/**
|
|
57
|
+
* The head state of an audit chain: enough to append the next entry.
|
|
58
|
+
*/
|
|
59
|
+
export interface ChainHead {
|
|
60
|
+
nextSeq: number;
|
|
61
|
+
prevHash: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read the chain head from an existing audit file. Verifies the whole chain
|
|
65
|
+
* during read. If the file does not exist or is empty, returns the genesis head.
|
|
66
|
+
*/
|
|
67
|
+
export declare function readHead(path: string): ChainHead;
|
|
68
|
+
/**
|
|
69
|
+
* Append-only audit writer with fsync after every write.
|
|
70
|
+
*
|
|
71
|
+
* Typical use:
|
|
72
|
+
* const w = new AuditWriter('/path/to/audit.log');
|
|
73
|
+
* w.append({ kind: 'eth_sign_message', portal: 'eth:bot', payload, decision: 'allow', sig });
|
|
74
|
+
* w.close();
|
|
75
|
+
*
|
|
76
|
+
* The seq and prev_hash fields are managed by the writer; callers supply
|
|
77
|
+
* everything else.
|
|
78
|
+
*/
|
|
79
|
+
export declare class AuditWriter {
|
|
80
|
+
#private;
|
|
81
|
+
readonly path: string;
|
|
82
|
+
constructor(path: string, opts?: {
|
|
83
|
+
now?: () => number;
|
|
84
|
+
});
|
|
85
|
+
get head(): ChainHead;
|
|
86
|
+
append(input: {
|
|
87
|
+
kind: string;
|
|
88
|
+
portal: string;
|
|
89
|
+
payload: unknown;
|
|
90
|
+
decision: AuditDecision;
|
|
91
|
+
reason?: string;
|
|
92
|
+
sig?: string;
|
|
93
|
+
}): StoredAuditEntry;
|
|
94
|
+
close(): void;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/audit/log.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAElE,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,SAAS,QAAiB,CAAC;AACxC,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBACvB,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAKxC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAuBpD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,CAE7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAE9D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CA4CxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,EAAE,CA8BpE;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAgBhD;AAED;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAMV,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;KAAO;IAM3D,IAAI,IAAI,IAAI,SAAS,CAEpB;IAED,MAAM,CAAC,KAAK,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,aAAa,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,GAAG,gBAAgB;IA4BpB,KAAK,IAAI,IAAI;CAGd"}
|