@conarium-ai/core 0.2.9 → 0.2.10
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/CHANGELOG.md +15 -0
- package/LIMITATIONS.md +49 -0
- package/LIMITATIONS.tr.md +49 -0
- package/README.md +11 -2
- package/SECURITY.md +14 -0
- package/bin/conarium-anchor-upgrade.mjs +10 -43
- package/bin/conarium-doctor.mjs +13 -17
- package/bin/conarium-stamp.mjs +4 -13
- package/bin/conarium-verify.mjs +13 -62
- package/deploy/anchor-service/README.md +3 -4
- package/dist/anchor-service.d.ts.map +1 -1
- package/dist/anchor-service.js +11 -26
- package/dist/anchor-service.js.map +1 -1
- package/dist/anchor.d.ts +6 -31
- package/dist/anchor.d.ts.map +1 -1
- package/dist/anchor.js +15 -65
- package/dist/anchor.js.map +1 -1
- package/dist/ots/calendar.d.ts +11 -0
- package/dist/ots/calendar.d.ts.map +1 -0
- package/dist/ots/calendar.js +93 -0
- package/dist/ots/calendar.js.map +1 -0
- package/dist/ots/client.d.ts +29 -0
- package/dist/ots/client.d.ts.map +1 -0
- package/dist/ots/client.js +102 -0
- package/dist/ots/client.js.map +1 -0
- package/dist/ots/codec.d.ts +26 -0
- package/dist/ots/codec.d.ts.map +1 -0
- package/dist/ots/codec.js +92 -0
- package/dist/ots/codec.js.map +1 -0
- package/dist/ots/format.d.ts +60 -0
- package/dist/ots/format.d.ts.map +1 -0
- package/dist/ots/format.js +232 -0
- package/dist/ots/format.js.map +1 -0
- package/docs/security/PENTEST-SCOPE.md +90 -0
- package/docs/security/THREAT-MODEL.md +116 -0
- package/package.json +5 -12
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTimestamps detached-proof format (read/write).
|
|
3
|
+
* Hashing uses Node `crypto`. This is the published OTS binary layout, not a new scheme.
|
|
4
|
+
*/
|
|
5
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
6
|
+
import { OtsError, Reader, Writer } from './codec.js';
|
|
7
|
+
export const HEADER_MAGIC = Buffer.from([
|
|
8
|
+
0x00, 0x4f, 0x70, 0x65, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x73, 0x00, 0x00, 0x50, 0x72,
|
|
9
|
+
0x6f, 0x6f, 0x66, 0x00, 0xbf, 0x89, 0xe2, 0xe8, 0x84, 0xe8, 0x92, 0x94,
|
|
10
|
+
]);
|
|
11
|
+
const MAJOR_VERSION = 1;
|
|
12
|
+
const TAG_ATTESTATION = 0x00;
|
|
13
|
+
const TAG_SEPARATOR = 0xff;
|
|
14
|
+
const PENDING_TAG = Buffer.from([0x83, 0xdf, 0xe3, 0x0d, 0x2e, 0xf9, 0x0c, 0x8e]);
|
|
15
|
+
const BITCOIN_TAG = Buffer.from([0x05, 0x88, 0x96, 0x0d, 0x73, 0xd7, 0x19, 0x01]);
|
|
16
|
+
export function applyOp(op, msg) {
|
|
17
|
+
switch (op.kind) {
|
|
18
|
+
case 'sha256':
|
|
19
|
+
return createHash('sha256').update(msg).digest();
|
|
20
|
+
case 'sha1':
|
|
21
|
+
return createHash('sha1').update(msg).digest();
|
|
22
|
+
case 'ripemd160':
|
|
23
|
+
return createHash('ripemd160').update(msg).digest();
|
|
24
|
+
case 'append':
|
|
25
|
+
return Buffer.concat([msg, op.arg]);
|
|
26
|
+
case 'prepend':
|
|
27
|
+
return Buffer.concat([op.arg, msg]);
|
|
28
|
+
case 'reverse':
|
|
29
|
+
return Buffer.from(msg).reverse();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function readOp(reader, tag) {
|
|
33
|
+
if (tag === 0x08)
|
|
34
|
+
return { kind: 'sha256' };
|
|
35
|
+
if (tag === 0x02)
|
|
36
|
+
return { kind: 'sha1' };
|
|
37
|
+
if (tag === 0x03)
|
|
38
|
+
return { kind: 'ripemd160' };
|
|
39
|
+
if (tag === 0xf0)
|
|
40
|
+
return { kind: 'append', arg: reader.readVarbytes() };
|
|
41
|
+
if (tag === 0xf1)
|
|
42
|
+
return { kind: 'prepend', arg: reader.readVarbytes() };
|
|
43
|
+
if (tag === 0xf2)
|
|
44
|
+
return { kind: 'reverse' };
|
|
45
|
+
throw new OtsError(`unsupported OTS operation tag 0x${tag.toString(16)}`);
|
|
46
|
+
}
|
|
47
|
+
function writeOp(writer, op) {
|
|
48
|
+
switch (op.kind) {
|
|
49
|
+
case 'sha256':
|
|
50
|
+
writer.writeByte(0x08);
|
|
51
|
+
return;
|
|
52
|
+
case 'sha1':
|
|
53
|
+
writer.writeByte(0x02);
|
|
54
|
+
return;
|
|
55
|
+
case 'ripemd160':
|
|
56
|
+
writer.writeByte(0x03);
|
|
57
|
+
return;
|
|
58
|
+
case 'append':
|
|
59
|
+
writer.writeByte(0xf0);
|
|
60
|
+
writer.writeVarbytes(op.arg);
|
|
61
|
+
return;
|
|
62
|
+
case 'prepend':
|
|
63
|
+
writer.writeByte(0xf1);
|
|
64
|
+
writer.writeVarbytes(op.arg);
|
|
65
|
+
return;
|
|
66
|
+
case 'reverse':
|
|
67
|
+
writer.writeByte(0xf2);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function readAttestation(reader) {
|
|
72
|
+
const tag = reader.read(8);
|
|
73
|
+
const payload = reader.readVarbytes(8192);
|
|
74
|
+
const inner = new Reader(payload);
|
|
75
|
+
if (tag.equals(PENDING_TAG)) {
|
|
76
|
+
const uriBytes = inner.readVarbytes(1000);
|
|
77
|
+
return { kind: 'pending', uri: uriBytes.toString('ascii') };
|
|
78
|
+
}
|
|
79
|
+
if (tag.equals(BITCOIN_TAG)) {
|
|
80
|
+
return { kind: 'bitcoin', height: inner.readVaruint() };
|
|
81
|
+
}
|
|
82
|
+
return { kind: 'unknown', tag, payload };
|
|
83
|
+
}
|
|
84
|
+
function writeAttestation(writer, att) {
|
|
85
|
+
const payload = new Writer();
|
|
86
|
+
let tag;
|
|
87
|
+
if (att.kind === 'pending') {
|
|
88
|
+
tag = PENDING_TAG;
|
|
89
|
+
payload.writeVarbytes(Buffer.from(att.uri, 'ascii'));
|
|
90
|
+
}
|
|
91
|
+
else if (att.kind === 'bitcoin') {
|
|
92
|
+
tag = BITCOIN_TAG;
|
|
93
|
+
payload.writeVaruint(att.height);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
tag = att.tag;
|
|
97
|
+
payload.write(att.payload);
|
|
98
|
+
}
|
|
99
|
+
writer.write(tag);
|
|
100
|
+
writer.writeVarbytes(payload.toBuffer());
|
|
101
|
+
}
|
|
102
|
+
export function deserializeTimestamp(reader, initialMsg) {
|
|
103
|
+
const self = { msg: Buffer.from(initialMsg), attestations: [], ops: [] };
|
|
104
|
+
const take = (tag) => {
|
|
105
|
+
if (tag === TAG_ATTESTATION) {
|
|
106
|
+
self.attestations.push(readAttestation(reader));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const op = readOp(reader, tag);
|
|
110
|
+
const nextMsg = applyOp(op, self.msg);
|
|
111
|
+
self.ops.push({ op, next: deserializeTimestamp(reader, nextMsg) });
|
|
112
|
+
};
|
|
113
|
+
let tag = reader.readByte();
|
|
114
|
+
while (tag === TAG_SEPARATOR) {
|
|
115
|
+
take(reader.readByte());
|
|
116
|
+
tag = reader.readByte();
|
|
117
|
+
}
|
|
118
|
+
take(tag);
|
|
119
|
+
return self;
|
|
120
|
+
}
|
|
121
|
+
function attestationOrder(a, b) {
|
|
122
|
+
const rank = (x) => (x.kind === 'bitcoin' ? 0 : x.kind === 'pending' ? 1 : 2);
|
|
123
|
+
const d = rank(a) - rank(b);
|
|
124
|
+
if (d !== 0)
|
|
125
|
+
return d;
|
|
126
|
+
if (a.kind === 'pending' && b.kind === 'pending')
|
|
127
|
+
return a.uri.localeCompare(b.uri);
|
|
128
|
+
if (a.kind === 'bitcoin' && b.kind === 'bitcoin')
|
|
129
|
+
return a.height - b.height;
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
132
|
+
export function serializeTimestamp(writer, ts) {
|
|
133
|
+
const atts = [...ts.attestations].sort(attestationOrder);
|
|
134
|
+
const ops = ts.ops;
|
|
135
|
+
if (atts.length === 0 && ops.length === 0)
|
|
136
|
+
throw new OtsError('empty timestamp cannot be serialized');
|
|
137
|
+
if (ops.length === 0) {
|
|
138
|
+
for (let i = 0; i < atts.length - 1; i++) {
|
|
139
|
+
writer.writeByte(TAG_SEPARATOR);
|
|
140
|
+
writer.writeByte(TAG_ATTESTATION);
|
|
141
|
+
writeAttestation(writer, atts[i]);
|
|
142
|
+
}
|
|
143
|
+
writer.writeByte(TAG_ATTESTATION);
|
|
144
|
+
writeAttestation(writer, atts[atts.length - 1]);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (atts.length > 0) {
|
|
148
|
+
for (const att of atts) {
|
|
149
|
+
writer.writeByte(TAG_SEPARATOR);
|
|
150
|
+
writer.writeByte(TAG_ATTESTATION);
|
|
151
|
+
writeAttestation(writer, att);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
for (let i = 0; i < ops.length; i++) {
|
|
155
|
+
if (i < ops.length - 1)
|
|
156
|
+
writer.writeByte(TAG_SEPARATOR);
|
|
157
|
+
writeOp(writer, ops[i].op);
|
|
158
|
+
serializeTimestamp(writer, ops[i].next);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export function deserializeDetached(bytes) {
|
|
162
|
+
const reader = new Reader(bytes);
|
|
163
|
+
reader.assertMagic(HEADER_MAGIC);
|
|
164
|
+
const major = reader.readVaruint();
|
|
165
|
+
if (major !== MAJOR_VERSION)
|
|
166
|
+
throw new OtsError(`unsupported OTS major version ${major}`);
|
|
167
|
+
const hashTag = reader.readByte();
|
|
168
|
+
if (hashTag !== 0x08)
|
|
169
|
+
throw new OtsError('only SHA-256 detached proofs are supported');
|
|
170
|
+
const fileHash = reader.read(32);
|
|
171
|
+
const timestamp = deserializeTimestamp(reader, fileHash);
|
|
172
|
+
reader.assertEof();
|
|
173
|
+
return { hashOp: 'sha256', fileHash, timestamp };
|
|
174
|
+
}
|
|
175
|
+
export function serializeDetached(proof) {
|
|
176
|
+
const writer = new Writer();
|
|
177
|
+
writer.write(HEADER_MAGIC);
|
|
178
|
+
writer.writeVaruint(MAJOR_VERSION);
|
|
179
|
+
writer.writeByte(0x08);
|
|
180
|
+
writer.write(proof.fileHash);
|
|
181
|
+
serializeTimestamp(writer, proof.timestamp);
|
|
182
|
+
return writer.toBuffer();
|
|
183
|
+
}
|
|
184
|
+
export function fileDigest(proof) {
|
|
185
|
+
return proof.fileHash;
|
|
186
|
+
}
|
|
187
|
+
export function collectAttestations(ts) {
|
|
188
|
+
const out = [];
|
|
189
|
+
for (const attestation of ts.attestations)
|
|
190
|
+
out.push({ msg: ts.msg, attestation });
|
|
191
|
+
for (const { next } of ts.ops)
|
|
192
|
+
out.push(...collectAttestations(next));
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
export function mergeTimestamp(into, other) {
|
|
196
|
+
if (!into.msg.equals(other.msg))
|
|
197
|
+
throw new OtsError('cannot merge timestamps for different messages');
|
|
198
|
+
into.attestations.push(...other.attestations);
|
|
199
|
+
for (const branch of other.ops) {
|
|
200
|
+
const existing = into.ops.find((b) => opsEqual(b.op, branch.op));
|
|
201
|
+
if (existing)
|
|
202
|
+
mergeTimestamp(existing.next, branch.next);
|
|
203
|
+
else
|
|
204
|
+
into.ops.push({ op: branch.op, next: branch.next });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function opsEqual(a, b) {
|
|
208
|
+
if (a.kind !== b.kind)
|
|
209
|
+
return false;
|
|
210
|
+
if ((a.kind === 'append' || a.kind === 'prepend') && (b.kind === 'append' || b.kind === 'prepend')) {
|
|
211
|
+
return a.arg.equals(b.arg);
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
/** Single-file stamp tree: fileHash —append(nonce16)→ —sha256→ tip (calendar attestations land on tip). */
|
|
216
|
+
export function stampSkeleton(fileHash, nonce = randomBytes(16)) {
|
|
217
|
+
const appended = applyOp({ kind: 'append', arg: nonce }, fileHash);
|
|
218
|
+
const tipMsg = applyOp({ kind: 'sha256' }, appended);
|
|
219
|
+
const tip = { msg: tipMsg, attestations: [], ops: [] };
|
|
220
|
+
const mid = { msg: appended, attestations: [], ops: [{ op: { kind: 'sha256' }, next: tip }] };
|
|
221
|
+
const root = { msg: fileHash, attestations: [], ops: [{ op: { kind: 'append', arg: nonce }, next: mid }] };
|
|
222
|
+
return { proof: { hashOp: 'sha256', fileHash, timestamp: root }, tip };
|
|
223
|
+
}
|
|
224
|
+
export function nodesWithAttestations(ts) {
|
|
225
|
+
if (ts.attestations.length > 0)
|
|
226
|
+
return [ts];
|
|
227
|
+
return ts.ops.flatMap((b) => nodesWithAttestations(b.next));
|
|
228
|
+
}
|
|
229
|
+
export function hasBitcoinAttestation(ts) {
|
|
230
|
+
return collectAttestations(ts).some((x) => x.attestation.kind === 'bitcoin');
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/ots/format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;IACtC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAChH,IAAI,EAAE,IAAI,EAAE,IAAI,E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C,EAAa;IACjD,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAC3C,OAAO,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,EAAa;IACjD,OAAO,mBAAmB,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS,CAAC,CAAA;AAC9E,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Penetration-test scope
|
|
2
|
+
|
|
3
|
+
Hand this to an external tester on day one. It is a map, not a certificate.
|
|
4
|
+
There is **no independent pentest on file**. Completing this document does
|
|
5
|
+
not change that.
|
|
6
|
+
|
|
7
|
+
English only. No price, no duration, no firm names.
|
|
8
|
+
|
|
9
|
+
## In scope
|
|
10
|
+
|
|
11
|
+
| Surface | What to hit | Expected behaviour (violation = finding) |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| MCP stdio / HTTP | `query`, `list_tables`, `describe_table`, `search` | Denied table → deny + receipt. Write SQL → refuse. Multi-statement → refuse. Row cap applied. Masked columns never reach the model in the clear. |
|
|
14
|
+
| SQL gate | UNION, quoted identifiers, function calls, `; DROP`, comments | Parser + `guardQuery` reject writes and unknown shape. A query that returns a denied table's data is a finding. |
|
|
15
|
+
| Receipt chain | Edit a line, swap two lines, delete a middle line, delete the tail, strip `sig` | `conarium-verify --pubkey` exits 10/11/12/13 as documented in `docs/RECEIPT-SPEC.md`. Tail delete **without** `--expect-count` exiting 0 is documented, not a finding. Tail delete **with** `--expect-count` exiting 0 is a finding. |
|
|
16
|
+
| Console | Auth, CSRF, session cookie, rate limit, config save | No token → 401/403. CSRF missing on cookie POST → 403. Rate limit before auth. Half-written config after crash is a finding. Bind default is `127.0.0.1`; a default bind on `0.0.0.0` is a finding. |
|
|
17
|
+
| Config loader | Missing file, empty `allowConnectors`, broken JSON, ReDoS-shaped `customPatterns` | Missing file → gateway starts empty (documented; doctor must flag it). Empty `allowConnectors` → deny all / refuse boot. Broken pattern → config rejected. |
|
|
18
|
+
| HTTP sessions | Reuse `Mcp-Session-Id` with a *different* valid token | 403. Same token → proceed. `test/session_owner.test.mjs`. |
|
|
19
|
+
| OpenAPI connector | SSRF / private-range redirect | HTTPS required. Host must be on `allowedBaseUrls`. DNS rebinding TOCTOU is a **known accepted gap** — see `SECURITY.md`. Report it if you can exploit it without an operator-controlled hostname; that would upgrade the finding. |
|
|
20
|
+
|
|
21
|
+
## Out of scope
|
|
22
|
+
|
|
23
|
+
- The operator's Postgres (or other) server itself.
|
|
24
|
+
- OS / hypervisor / physical access.
|
|
25
|
+
- Social engineering of the one-person team.
|
|
26
|
+
- Denial-of-service against public OpenTimestamps calendars or `blockstream.info`.
|
|
27
|
+
- Asking the model to "ignore previous instructions" as a *product* finding
|
|
28
|
+
unless it produces a policy bypass in the gateway (the model is not the gate).
|
|
29
|
+
|
|
30
|
+
## How to stand it up (first morning)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/dogrucanemek-alt/conarium.git
|
|
34
|
+
cd conarium
|
|
35
|
+
npm ci
|
|
36
|
+
npm run build
|
|
37
|
+
npx tsc --noEmit
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Write a throwaway config with `npx conarium-init --out /tmp/cnr-pt`.
|
|
41
|
+
Point the Postgres URL at a **disposable** database you control.
|
|
42
|
+
Fill `policy.allowTables`. Export `CONARIUM_AUDIT_SIGNING_KEY`.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx conarium-doctor --config /tmp/cnr-pt/conarium.config.json --no-net
|
|
46
|
+
# stdio MCP
|
|
47
|
+
npx conarium --config /tmp/cnr-pt/conarium.config.json
|
|
48
|
+
# console (loopback)
|
|
49
|
+
CONARIUM_CONSOLE_TOKEN='<≥24 chars>' npx conarium-console
|
|
50
|
+
# HTTP gateway
|
|
51
|
+
CONARIUM_MCP_TOKEN='<≥24 chars>' npx conarium --http --config /tmp/cnr-pt/conarium.config.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Do not point this at a production ERP. The only production install this
|
|
55
|
+
project has is the author's company; it is not a test target.
|
|
56
|
+
|
|
57
|
+
## Tests already in the repo — do not redo from zero
|
|
58
|
+
|
|
59
|
+
| Suite | Command | What it already covers |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| Unit | `npx vitest run` | Governance, masking, receipts, sessions, rate limit, custom patterns |
|
|
62
|
+
| Adversarial checks | `npm run test:checks` | Doctor, console auth/CSRF/handoff, init, pack leak, connectors, lineage, hardening, OTS fixtures, vectors, HTTP e2e |
|
|
63
|
+
| Conformance vectors | `npm run test:vectors` | Frozen receipt cases + expected exit codes in `test-vectors/manifest.json` |
|
|
64
|
+
| Red team | `npx vitest run redteam` | Query-time and result-time attacks (`redteam/attacks/`) |
|
|
65
|
+
| Receipt spec | `docs/RECEIPT-SPEC.md` | Exit codes 0, 10–15, 20, 40, 50 |
|
|
66
|
+
|
|
67
|
+
A finding that is already asserted in one of those files is a **regression**,
|
|
68
|
+
not a new class. Cite the test.
|
|
69
|
+
|
|
70
|
+
## Known documented gaps (do not bill as discovery)
|
|
71
|
+
|
|
72
|
+
These are already written down. Confirm they are still true; do not invoice
|
|
73
|
+
the first hour spent rediscovering them.
|
|
74
|
+
|
|
75
|
+
1. No SOC 2, no ISO, no independent pentest. (`LIMITATIONS.md`)
|
|
76
|
+
2. Not 1.0. API can break.
|
|
77
|
+
3. SQL is Postgres only.
|
|
78
|
+
4. Bare names and street addresses in free text are not detected.
|
|
79
|
+
5. One production install; 121,366 is that company's ERP and is not
|
|
80
|
+
externally verifiable.
|
|
81
|
+
6. Bus factor 1. Cryptography not formally audited.
|
|
82
|
+
7. Receipt tail truncation is invisible without an external pin.
|
|
83
|
+
8. OpenAPI DNS rebinding TOCTOU, accepted (`SECURITY.md`).
|
|
84
|
+
9. OpenTimestamps pending ≠ Bitcoin-confirmed. Explorer unreachable → 15.
|
|
85
|
+
|
|
86
|
+
## Reporting
|
|
87
|
+
|
|
88
|
+
Email **e.dogru@conarium.dev**. Include a reproduction. There is no bounty.
|
|
89
|
+
A report that says "we found no issues" is not an audit substitute and will
|
|
90
|
+
not be quoted as one.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Threat model
|
|
2
|
+
|
|
3
|
+
What an attacker can try. Not a sales page. Not an audit.
|
|
4
|
+
There is **no independent penetration test**. This document does not change that.
|
|
5
|
+
|
|
6
|
+
Measured against this repository (Conarium 0.2.x). Dates are when a fact was
|
|
7
|
+
recorded, not promises.
|
|
8
|
+
|
|
9
|
+
## Assets
|
|
10
|
+
|
|
11
|
+
| Asset | Why it matters | Where it lives |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| Customer PII / secrets in the database | The product exists to keep these off the model | Operator's Postgres (and other connectors) |
|
|
14
|
+
| Policy (allow/deny/mask/row-cap) | Whoever writes this decides what the model sees | `conarium.config.json`, console save path |
|
|
15
|
+
| Ed25519 signing key | Forges receipts if stolen | `audit-ed25519.pem` (mode 0600 where the OS allows) |
|
|
16
|
+
| Receipt / audit chain | Evidence of what was allowed, denied, masked | `audit.sink`, `audit.receiptSink` |
|
|
17
|
+
| Per-user tokens | Bind a person to a masking profile | `CONARIUM_TOKENS_FILE` / `conarium.tokens.json` |
|
|
18
|
+
| Console token | Opens the policy editor | `CONARIUM_CONSOLE_TOKEN`, `~/.conarium/console.token` |
|
|
19
|
+
| MCP token | Opens the HTTP gateway | `CONARIUM_MCP_TOKEN` |
|
|
20
|
+
|
|
21
|
+
## Actors
|
|
22
|
+
|
|
23
|
+
| Actor | Intent |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Honest developer | Uses Cursor/Copilot through the gateway as designed |
|
|
26
|
+
| Manipulated AI agent | Follows a prompt that tries to read denied tables, dump rows, or smuggle PII in free text |
|
|
27
|
+
| Malicious insider | Holds a valid token or the config; wants to widen policy or rewrite history |
|
|
28
|
+
| Process that bypasses the gateway | Connects to the database with the same or another credential, never through Conarium |
|
|
29
|
+
| Attacker on the console / HTTP port | Reaches loopback or a mis-bound interface; tries auth, CSRF, session swap |
|
|
30
|
+
|
|
31
|
+
A compromised operator is in scope as an actor and **out of scope as a defence**.
|
|
32
|
+
Whoever controls the config controls the policy. The code cannot save you from yourself.
|
|
33
|
+
|
|
34
|
+
## Trust boundaries
|
|
35
|
+
|
|
36
|
+
### 1. AI assistant ↔ gateway
|
|
37
|
+
|
|
38
|
+
**Today:** MCP stdio or Streamable HTTP. SQL is parsed (`pgsql-ast-parser`), not grepped.
|
|
39
|
+
Writes are refused by the connector. Tables not on `allowTables` are denied.
|
|
40
|
+
`maskColumns` plus content scanners run before the model sees a row.
|
|
41
|
+
Every tool call — allowed or denied — is supposed to write a signed receipt.
|
|
42
|
+
|
|
43
|
+
**Bypass surface:**
|
|
44
|
+
- A bare name in running prose is not detected. "Ahmet called" goes through.
|
|
45
|
+
- Street addresses are not detected.
|
|
46
|
+
- Passport numbers in free text (non-MRZ) are not detected.
|
|
47
|
+
- `allowTools` is fail-**open** when unset. Table policy is the real gate.
|
|
48
|
+
- HTTP sessions were once routable by `Mcp-Session-Id` alone (fixed 2026-08-12:
|
|
49
|
+
bound to a hash of the opening credential). Regression: `test/session_owner.test.mjs`.
|
|
50
|
+
- A missing config file does **not** stop the gateway. It starts with zero
|
|
51
|
+
connectors and governs nothing. `conarium-doctor` exists because of this.
|
|
52
|
+
|
|
53
|
+
### 2. Gateway ↔ database
|
|
54
|
+
|
|
55
|
+
**Today:** Connectors are read-only. `Governance.guardQuery` rejects writes,
|
|
56
|
+
multi-statement, and unknown AST. Row cap is applied in the engine.
|
|
57
|
+
Supabase REST and docs connectors have their own read-only paths.
|
|
58
|
+
|
|
59
|
+
**Bypass surface:**
|
|
60
|
+
- The database credential, once leaked, is a path around the gateway.
|
|
61
|
+
Conarium is not a firewall.
|
|
62
|
+
- `pg_stat_statements` reconciliation trusts the database's own counters.
|
|
63
|
+
An attacker who can falsify those counters is out of scope.
|
|
64
|
+
- OpenAPI connector: DNS rebinding / TOCTOU between `enforceSafeRemoteUrl`
|
|
65
|
+
and `fetch` is **accepted, not fixed** (`SECURITY.md`). Exploit requires an
|
|
66
|
+
operator-authored `allowedBaseUrls` entry under attacker control.
|
|
67
|
+
- SQL dialect is Postgres only. A query the parser does not understand is
|
|
68
|
+
denied — unless a future dialect is added badly, in which case the gate
|
|
69
|
+
fails open on that dialect. There is no second dialect in code.
|
|
70
|
+
|
|
71
|
+
### 3. Console ↔ operator
|
|
72
|
+
|
|
73
|
+
**Today:** Binds `127.0.0.1`. Token required. CSRF token on cookie sessions.
|
|
74
|
+
Rate limit runs **before** auth (the token is the thing being protected).
|
|
75
|
+
Config save is temp-file + `rename` in the same directory.
|
|
76
|
+
|
|
77
|
+
**Bypass surface:**
|
|
78
|
+
- Loopback is not a security boundary on a shared machine.
|
|
79
|
+
- `CONARIUM_CONSOLE_TOKEN` in the environment is as strong as the operator's
|
|
80
|
+
process list and shell history.
|
|
81
|
+
- The desktop shortcut stores the token in `~/.conarium/console.token` (0600).
|
|
82
|
+
Another local account that can read that file is the operator.
|
|
83
|
+
- Chat proxy (`api/chat.js`): anonymous access requires explicit
|
|
84
|
+
`CONARIUM_CHAT_PUBLIC=1`; missing config is 503, not "public".
|
|
85
|
+
|
|
86
|
+
### 4. Receipt file ↔ auditor
|
|
87
|
+
|
|
88
|
+
**Today:** Ed25519 + hash chain. `conarium-verify` imports nothing from `src/`.
|
|
89
|
+
Middle-gap deletion fails. Tail truncation does **not** fail unless
|
|
90
|
+
`--expect-count` / `--expect-last-hash` or an external anchor / reconcile.
|
|
91
|
+
Pending OpenTimestamps is disclosed as `pending`. Bitcoin upgrade is hours later.
|
|
92
|
+
|
|
93
|
+
**Bypass surface:**
|
|
94
|
+
- An operator can write false-but-well-formed receipts *before* anchoring.
|
|
95
|
+
Creation-time truth is not proven.
|
|
96
|
+
- `{hash, sig, anchor}` are excluded from the content hash. Ed25519-only
|
|
97
|
+
strip-all can pass a boot check; Ed25519 + HMAC catches it.
|
|
98
|
+
- A shorter leftover chain still verifies. That is structural, not a bug.
|
|
99
|
+
- Anchor calendars and `blockstream.info` are third parties. Unreachable →
|
|
100
|
+
exit 15 ("could not check"), not exit 0.
|
|
101
|
+
|
|
102
|
+
## Out of scope (stated so nobody bills hours here)
|
|
103
|
+
|
|
104
|
+
- The database's own authentication, authorization, encryption, backups.
|
|
105
|
+
- The operating system, disk encryption, process isolation, file permissions
|
|
106
|
+
beyond what this process sets on keys it writes.
|
|
107
|
+
- The network path in front of a reverse proxy (TLS, WAF, VPN).
|
|
108
|
+
- Hardware key storage (HSM, TPM, OS keychain). The signing key is a PEM file.
|
|
109
|
+
- The model leaking data it was *allowed* to see.
|
|
110
|
+
- An attacker who already has the operator's shell.
|
|
111
|
+
|
|
112
|
+
## What this document is not
|
|
113
|
+
|
|
114
|
+
It is not a pentest. It is not SOC 2. It is not a claim that the surfaces
|
|
115
|
+
above are closed. It is the list we would hand a tester so they spend time
|
|
116
|
+
on the weak points instead of rediscovering the product.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conarium-ai/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"//files-artefakt": "examples/ altindaki uretilmis dosyalar (ozel anahtar, makbuz/denetim JSONL) ELENIR. .gitignore npm'i baglamaz: izin listesinde 'examples' oldugu icin demoyu kosturmus bir makinede 'npm publish' _keys/audit-ed25519.pem'i (OZEL ANAHTAR) ve makbuzlari yayinliyordu. test/pack_artefakt.mjs bunu kilitler. Elemeler examples/ ile SINIRLI: test-vectors/ altindaki receipts.jsonl ve .pub.pem YAYINLANMAK ZORUNDA, yoksa ucuncu taraf konformans vektorlerini kosturamaz.",
|
|
5
5
|
"//files": "Pakete NE gireceginin izin listesi. Liste olmadan npm her seyi gonderiyordu: 296 dosya / 1.5 MB — CI workflowlari, gitleaks ayari, 137 KB pazarlama gorseli, sitenin api/chat.js dosyasi. Bir bankanin guvenlik ekibi tarball'i acip bunlari gorur. scripts/ BILEREK var: conarium-reconcile calisirken scripts/pg-snapshot.sql'e atif yapiyor, olmazsa kullanici destek maili yazar.",
|
|
6
6
|
"files": [
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"README.md",
|
|
26
26
|
"LICENSE",
|
|
27
27
|
"SECURITY.md",
|
|
28
|
+
"LIMITATIONS.md",
|
|
29
|
+
"LIMITATIONS.tr.md",
|
|
28
30
|
"CHANGELOG.md"
|
|
29
31
|
],
|
|
30
32
|
"description": "Governed MCP gateway for AI data access: policy enforcement and PII masking, an Ed25519-signed receipt per access that a third party verifies offline, coverage reconciliation against the database's own query counters to surface access that bypassed the gateway, and conformance vectors so the receipt format can be implemented without us. Self-hosted, MIT.",
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
"build": "tsc",
|
|
72
74
|
"test": "vitest run",
|
|
73
75
|
"test:anchor-verify": "npm run build && node test/anchor_verify.mjs",
|
|
74
|
-
"test:checks": "npm run build && node test/
|
|
76
|
+
"test:checks": "npm run build && node test/run-checks.mjs",
|
|
75
77
|
"test:all": "npm run lint && npm run test && npm run test:checks",
|
|
76
78
|
"dev": "tsx watch src/index.ts",
|
|
77
79
|
"start": "node dist/index.js",
|
|
@@ -95,18 +97,9 @@
|
|
|
95
97
|
"supertest": "^7.2.2",
|
|
96
98
|
"tsx": "^4.16.0",
|
|
97
99
|
"typescript": "^5.5.0",
|
|
98
|
-
"vitest": "^2.0.0"
|
|
99
|
-
"javascript-opentimestamps": "^0.4.5"
|
|
100
|
+
"vitest": "^2.0.0"
|
|
100
101
|
},
|
|
101
102
|
"engines": {
|
|
102
103
|
"node": ">=18"
|
|
103
|
-
},
|
|
104
|
-
"peerDependencies": {
|
|
105
|
-
"javascript-opentimestamps": "^0.4.5"
|
|
106
|
-
},
|
|
107
|
-
"peerDependenciesMeta": {
|
|
108
|
-
"javascript-opentimestamps": {
|
|
109
|
-
"optional": true
|
|
110
|
-
}
|
|
111
104
|
}
|
|
112
105
|
}
|