x402-engineer 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/AGENT.md +102 -0
- package/README.md +43 -0
- package/dist/cli.cjs +137 -0
- package/package.json +51 -0
- package/skills/stellar-dev/SKILL.md +146 -0
- package/skills/stellar-dev/advanced-patterns.md +188 -0
- package/skills/stellar-dev/api-rpc-horizon.md +521 -0
- package/skills/stellar-dev/common-pitfalls.md +510 -0
- package/skills/stellar-dev/contracts-soroban.md +565 -0
- package/skills/stellar-dev/ecosystem.md +430 -0
- package/skills/stellar-dev/frontend-stellar-sdk.md +651 -0
- package/skills/stellar-dev/resources.md +306 -0
- package/skills/stellar-dev/security.md +491 -0
- package/skills/stellar-dev/standards-reference.md +94 -0
- package/skills/stellar-dev/stellar-assets.md +419 -0
- package/skills/stellar-dev/testing.md +786 -0
- package/skills/stellar-dev/zk-proofs.md +136 -0
- package/skills/x402-add-paywall/SKILL.md +208 -0
- package/skills/x402-add-paywall/references/patterns.md +132 -0
- package/skills/x402-debug/SKILL.md +92 -0
- package/skills/x402-debug/references/checklist.md +146 -0
- package/skills/x402-explain/SKILL.md +136 -0
- package/skills/x402-init/SKILL.md +129 -0
- package/skills/x402-init/templates/env-example.md +17 -0
- package/skills/x402-init/templates/express/config.ts.md +29 -0
- package/skills/x402-init/templates/express/server.ts.md +30 -0
- package/skills/x402-init/templates/fastify/adapter.ts.md +66 -0
- package/skills/x402-init/templates/fastify/config.ts.md +29 -0
- package/skills/x402-init/templates/fastify/server.ts.md +90 -0
- package/skills/x402-init/templates/hono/config.ts.md +29 -0
- package/skills/x402-init/templates/hono/server.ts.md +31 -0
- package/skills/x402-init/templates/next-app-router/config.ts.md +29 -0
- package/skills/x402-init/templates/next-app-router/server.ts.md +31 -0
- package/skills/x402-stellar/SKILL.md +139 -0
- package/skills/x402-stellar/references/api.md +237 -0
- package/skills/x402-stellar/references/patterns.md +276 -0
- package/skills/x402-stellar/references/setup.md +138 -0
- package/skills/x402-stellar/scripts/check-deps.js +218 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
# Stellar Security Checklist (Soroban + Classic)
|
|
2
|
+
|
|
3
|
+
## Core Principle
|
|
4
|
+
|
|
5
|
+
Assume the attacker controls:
|
|
6
|
+
- All arguments passed to contract functions
|
|
7
|
+
- Transaction ordering and timing
|
|
8
|
+
- All accounts except those requiring signatures
|
|
9
|
+
- The ability to create contracts that mimic your interface
|
|
10
|
+
|
|
11
|
+
## Soroban Security Advantages
|
|
12
|
+
|
|
13
|
+
Soroban's architecture prevents certain vulnerability classes by design:
|
|
14
|
+
|
|
15
|
+
### No Delegate Call
|
|
16
|
+
Unlike Ethereum, Soroban has no `delegatecall` equivalent. Contracts cannot execute arbitrary bytecode in their context, eliminating proxy-based attacks.
|
|
17
|
+
|
|
18
|
+
### No Classical Reentrancy
|
|
19
|
+
Soroban's synchronous execution model prevents the cross-contract reentrancy that plagues Ethereum. Self-reentrancy is possible but rarely exploitable.
|
|
20
|
+
|
|
21
|
+
### Explicit Authorization
|
|
22
|
+
Authorization is opt-in via `require_auth()`, making it explicit which operations need signatures.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Vulnerability Categories
|
|
27
|
+
|
|
28
|
+
### 1. Missing Authorization Checks
|
|
29
|
+
|
|
30
|
+
**Risk**: Anyone can call privileged functions without proper verification.
|
|
31
|
+
|
|
32
|
+
**Attack**: Attacker calls admin-only functions, drains funds, or modifies critical state.
|
|
33
|
+
|
|
34
|
+
**Vulnerable Code**:
|
|
35
|
+
```rust
|
|
36
|
+
// BAD: No authorization check
|
|
37
|
+
pub fn withdraw(env: Env, to: Address, amount: i128) {
|
|
38
|
+
transfer_tokens(&env, &to, amount);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Secure Code**:
|
|
43
|
+
```rust
|
|
44
|
+
// GOOD: Requires authorization from admin
|
|
45
|
+
pub fn withdraw(env: Env, to: Address, amount: i128) {
|
|
46
|
+
let admin: Address = env.storage().instance().get(&DataKey::Admin).unwrap();
|
|
47
|
+
admin.require_auth();
|
|
48
|
+
transfer_tokens(&env, &to, amount);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Prevention**: Always use `require_auth()` on the caller or an admin address. See [contracts-soroban.md](contracts-soroban.md) for full authorization patterns (direct auth, admin helpers, `require_auth_for_args`).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### 2. Reinitialization Attacks
|
|
57
|
+
|
|
58
|
+
**Risk**: Initialization function can be called multiple times, allowing attacker to overwrite admin or critical state.
|
|
59
|
+
|
|
60
|
+
**Attack**: Attacker reinitializes contract to become the admin, then drains assets.
|
|
61
|
+
|
|
62
|
+
**Vulnerable Code**:
|
|
63
|
+
```rust
|
|
64
|
+
// BAD: Can be called multiple times
|
|
65
|
+
pub fn initialize(env: Env, admin: Address) {
|
|
66
|
+
env.storage().instance().set(&DataKey::Admin, &admin);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Secure Code**:
|
|
71
|
+
```rust
|
|
72
|
+
// GOOD: Prevents reinitialization
|
|
73
|
+
pub fn initialize(env: Env, admin: Address) {
|
|
74
|
+
if env.storage().instance().has(&DataKey::Initialized) {
|
|
75
|
+
panic!("already initialized");
|
|
76
|
+
}
|
|
77
|
+
env.storage().instance().set(&DataKey::Admin, &admin);
|
|
78
|
+
env.storage().instance().set(&DataKey::Initialized, &true);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Alternative: Check for admin existence
|
|
82
|
+
pub fn initialize(env: Env, admin: Address) {
|
|
83
|
+
if env.storage().instance().has(&DataKey::Admin) {
|
|
84
|
+
panic!("already initialized");
|
|
85
|
+
}
|
|
86
|
+
env.storage().instance().set(&DataKey::Admin, &admin);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### 3. Arbitrary Contract Calls
|
|
93
|
+
|
|
94
|
+
**Risk**: Contract calls whatever address is passed as parameter without validation.
|
|
95
|
+
|
|
96
|
+
**Attack**: Attacker passes malicious contract that mimics expected interface but behaves differently.
|
|
97
|
+
|
|
98
|
+
**Vulnerable Code**:
|
|
99
|
+
```rust
|
|
100
|
+
// BAD: Calls any contract passed as parameter
|
|
101
|
+
pub fn swap(env: Env, token: Address, amount: i128) {
|
|
102
|
+
let client = token::Client::new(&env, &token);
|
|
103
|
+
client.transfer(...); // Could be malicious contract
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Secure Code**:
|
|
108
|
+
```rust
|
|
109
|
+
// GOOD: Validate against known allowlist
|
|
110
|
+
pub fn swap(env: Env, token: Address, amount: i128) {
|
|
111
|
+
let allowed_tokens: Vec<Address> = env.storage()
|
|
112
|
+
.instance()
|
|
113
|
+
.get(&DataKey::AllowedTokens)
|
|
114
|
+
.unwrap();
|
|
115
|
+
|
|
116
|
+
if !allowed_tokens.contains(&token) {
|
|
117
|
+
panic!("token not allowed");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let client = token::Client::new(&env, &token);
|
|
121
|
+
client.transfer(...);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Or validate against Stellar Asset Contract
|
|
125
|
+
pub fn swap_sac(env: Env, asset: Address, amount: i128) {
|
|
126
|
+
// SACs have known, predictable addresses
|
|
127
|
+
// Verify it's a legitimate SAC if needed
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
### 4. Integer Overflow/Underflow
|
|
134
|
+
|
|
135
|
+
**Risk**: Arithmetic operations overflow or underflow, causing unexpected values.
|
|
136
|
+
|
|
137
|
+
**Attack**: Attacker manipulates amounts to cause overflow, bypassing balance checks.
|
|
138
|
+
|
|
139
|
+
**Vulnerable Code**:
|
|
140
|
+
```rust
|
|
141
|
+
// BAD: Unchecked arithmetic
|
|
142
|
+
pub fn deposit(env: Env, user: Address, amount: i128) {
|
|
143
|
+
let balance: i128 = get_balance(&env, &user);
|
|
144
|
+
set_balance(&env, &user, balance + amount); // Can overflow
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Secure Code**:
|
|
149
|
+
```rust
|
|
150
|
+
// GOOD: Use checked arithmetic
|
|
151
|
+
pub fn deposit(env: Env, user: Address, amount: i128) {
|
|
152
|
+
let balance: i128 = get_balance(&env, &user);
|
|
153
|
+
let new_balance = balance.checked_add(amount)
|
|
154
|
+
.expect("overflow");
|
|
155
|
+
set_balance(&env, &user, new_balance);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Also validate inputs
|
|
159
|
+
pub fn deposit(env: Env, user: Address, amount: i128) {
|
|
160
|
+
if amount <= 0 {
|
|
161
|
+
panic!("invalid amount");
|
|
162
|
+
}
|
|
163
|
+
// ... rest of logic
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### 5. Storage Key Collisions
|
|
170
|
+
|
|
171
|
+
**Risk**: Different data types share the same storage key, causing data corruption.
|
|
172
|
+
|
|
173
|
+
**Attack**: Attacker manipulates one type of data to corrupt another.
|
|
174
|
+
|
|
175
|
+
**Vulnerable Code**:
|
|
176
|
+
```rust
|
|
177
|
+
// BAD: Same prefix for different data
|
|
178
|
+
env.storage().persistent().set(&symbol_short!("data"), &user_balance);
|
|
179
|
+
env.storage().persistent().set(&symbol_short!("data"), &config); // Overwrites!
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Secure Code**:
|
|
183
|
+
```rust
|
|
184
|
+
// GOOD: Use typed enum for keys
|
|
185
|
+
#[contracttype]
|
|
186
|
+
#[derive(Clone)]
|
|
187
|
+
pub enum DataKey {
|
|
188
|
+
Admin,
|
|
189
|
+
Balance(Address),
|
|
190
|
+
Config,
|
|
191
|
+
Allowance(Address, Address),
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
env.storage().persistent().set(&DataKey::Balance(user), &balance);
|
|
195
|
+
env.storage().instance().set(&DataKey::Config, &config);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### 6. Timing/State Race Conditions
|
|
201
|
+
|
|
202
|
+
**Risk**: Contract state changes between check and use.
|
|
203
|
+
|
|
204
|
+
**Attack**: In multi-transaction scenarios, attacker exploits gap between validation and action.
|
|
205
|
+
|
|
206
|
+
**Prevention**:
|
|
207
|
+
```rust
|
|
208
|
+
// Use atomic operations where possible
|
|
209
|
+
pub fn swap(env: Env, user: Address, amount_in: i128, min_out: i128) {
|
|
210
|
+
user.require_auth();
|
|
211
|
+
|
|
212
|
+
// Perform all checks and state changes atomically
|
|
213
|
+
let balance = get_balance(&env, &user);
|
|
214
|
+
if balance < amount_in {
|
|
215
|
+
panic!("insufficient balance");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let amount_out = calculate_output(amount_in);
|
|
219
|
+
if amount_out < min_out {
|
|
220
|
+
panic!("slippage exceeded");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Update all state together
|
|
224
|
+
set_balance(&env, &user, balance - amount_in);
|
|
225
|
+
transfer_output(&env, &user, amount_out);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### 7. TTL/Archival Vulnerabilities
|
|
232
|
+
|
|
233
|
+
**Risk**: Critical contract data gets archived, breaking functionality.
|
|
234
|
+
|
|
235
|
+
**Attack**: Attacker waits for data to be archived, then exploits the missing state.
|
|
236
|
+
|
|
237
|
+
**Prevention**:
|
|
238
|
+
```rust
|
|
239
|
+
// Extend TTL for critical data
|
|
240
|
+
pub fn critical_operation(env: Env) {
|
|
241
|
+
// Always extend instance storage
|
|
242
|
+
env.storage().instance().extend_ttl(
|
|
243
|
+
100, // threshold
|
|
244
|
+
518400, // extend_to (~30 days)
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
// Extend specific persistent keys
|
|
248
|
+
env.storage().persistent().extend_ttl(
|
|
249
|
+
&DataKey::CriticalData,
|
|
250
|
+
100,
|
|
251
|
+
518400,
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Consider restoration costs in design
|
|
256
|
+
// Archived data can be restored, but requires transaction
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
### 8. Cross-Contract Call Validation
|
|
262
|
+
|
|
263
|
+
**Risk**: Trusting return values from untrusted contracts.
|
|
264
|
+
|
|
265
|
+
**Attack**: Malicious contract returns false data, causing incorrect state updates.
|
|
266
|
+
|
|
267
|
+
**Prevention**:
|
|
268
|
+
```rust
|
|
269
|
+
// Validate all external data
|
|
270
|
+
pub fn process_oracle_price(env: Env, oracle: Address, asset: Address) -> i128 {
|
|
271
|
+
// Validate oracle is trusted
|
|
272
|
+
let trusted_oracles: Vec<Address> = env.storage()
|
|
273
|
+
.instance()
|
|
274
|
+
.get(&DataKey::TrustedOracles)
|
|
275
|
+
.unwrap();
|
|
276
|
+
|
|
277
|
+
if !trusted_oracles.contains(&oracle) {
|
|
278
|
+
panic!("untrusted oracle");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
let price: i128 = oracle_client.get_price(&asset);
|
|
282
|
+
|
|
283
|
+
// Sanity check the value
|
|
284
|
+
if price <= 0 || price > MAX_REASONABLE_PRICE {
|
|
285
|
+
panic!("invalid price");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
price
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Classic Stellar Security
|
|
295
|
+
|
|
296
|
+
### Trustline Attacks
|
|
297
|
+
|
|
298
|
+
**Risk**: Users create trustlines to malicious assets that look legitimate.
|
|
299
|
+
|
|
300
|
+
**Prevention**:
|
|
301
|
+
- Verify asset issuer before creating trustlines
|
|
302
|
+
- Use well-known asset lists (stellar.toml)
|
|
303
|
+
- Display full asset code + issuer in UIs
|
|
304
|
+
|
|
305
|
+
### Clawback Awareness
|
|
306
|
+
|
|
307
|
+
**Risk**: Assets with clawback enabled can be seized by issuer.
|
|
308
|
+
|
|
309
|
+
**Prevention**:
|
|
310
|
+
```typescript
|
|
311
|
+
// Check if clawback is enabled
|
|
312
|
+
const issuerAccount = await server.loadAccount(asset.issuer);
|
|
313
|
+
const clawbackEnabled = issuerAccount.flags.auth_clawback_enabled;
|
|
314
|
+
|
|
315
|
+
if (clawbackEnabled) {
|
|
316
|
+
// Warn user or reject asset
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Account Merge Attacks
|
|
321
|
+
|
|
322
|
+
**Risk**: Merged accounts can be recreated with different configuration.
|
|
323
|
+
|
|
324
|
+
**Prevention**:
|
|
325
|
+
- Validate account state before critical operations
|
|
326
|
+
- Don't cache account data long-term
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Soroban-Specific Checklist
|
|
331
|
+
|
|
332
|
+
### Contract Development
|
|
333
|
+
- [ ] All privileged functions require appropriate authorization
|
|
334
|
+
- [ ] Initialization can only happen once
|
|
335
|
+
- [ ] External contract calls are validated against allowlists
|
|
336
|
+
- [ ] All arithmetic uses checked operations
|
|
337
|
+
- [ ] Storage keys are typed and collision-free
|
|
338
|
+
- [ ] Critical data TTLs are extended proactively
|
|
339
|
+
- [ ] Input validation on all public functions
|
|
340
|
+
- [ ] Events emitted for auditable state changes
|
|
341
|
+
|
|
342
|
+
### Storage Security
|
|
343
|
+
- [ ] Sensitive data uses appropriate storage type
|
|
344
|
+
- [ ] Instance storage for shared/admin data
|
|
345
|
+
- [ ] Persistent storage for user-specific data
|
|
346
|
+
- [ ] Temporary storage only for truly temporary data
|
|
347
|
+
- [ ] TTL management strategy documented
|
|
348
|
+
|
|
349
|
+
### Cross-Contract Calls
|
|
350
|
+
- [ ] Called contracts are validated or allowlisted
|
|
351
|
+
- [ ] Return values are sanity-checked
|
|
352
|
+
- [ ] Failure cases handled gracefully
|
|
353
|
+
- [ ] No excessive trust in external state
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Client-Side Checklist
|
|
358
|
+
|
|
359
|
+
- [ ] Network passphrase validated before signing
|
|
360
|
+
- [ ] Transaction simulation before submission
|
|
361
|
+
- [ ] Clear display of all operation details
|
|
362
|
+
- [ ] Confirmation for high-value transactions
|
|
363
|
+
- [ ] Handle all error states gracefully
|
|
364
|
+
- [ ] Don't trust client-side validation alone
|
|
365
|
+
- [ ] Verify contract addresses against known deployments
|
|
366
|
+
- [ ] Check asset trustline status before transfers
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## Security Review Questions
|
|
371
|
+
|
|
372
|
+
1. Can anyone call admin functions without authorization?
|
|
373
|
+
2. Can the contract be reinitialized?
|
|
374
|
+
3. Are all external contract calls validated?
|
|
375
|
+
4. Is arithmetic safe from overflow/underflow?
|
|
376
|
+
5. Can storage keys collide?
|
|
377
|
+
6. Will critical data survive archival?
|
|
378
|
+
7. Are cross-contract return values validated?
|
|
379
|
+
8. Can timing attacks exploit state changes?
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## Bug Bounty Programs
|
|
384
|
+
|
|
385
|
+
### Immunefi — Stellar Core (up to $250K)
|
|
386
|
+
- **URL**: https://immunefi.com/bug-bounty/stellar/
|
|
387
|
+
- **Scope**: stellar-core, rs-soroban-sdk, rs-soroban-env, soroban-tools (CLI + RPC), js-soroban-client, rs-stellar-xdr, wasmi fork
|
|
388
|
+
- **Rewards**: Critical $50K–$250K, High $10K–$50K, Medium $5K, Low $1K
|
|
389
|
+
- **Payment**: USD-denominated, paid in XLM. KYC required.
|
|
390
|
+
- **Rules**: PoC required. Test on local forks only (no mainnet/testnet).
|
|
391
|
+
|
|
392
|
+
### Immunefi — OpenZeppelin on Stellar (up to $25K)
|
|
393
|
+
- **URL**: https://immunefi.com/bug-bounty/openzeppelin-stellar/
|
|
394
|
+
- **Scope**: OpenZeppelin Stellar Contracts library
|
|
395
|
+
- **Max payout**: $25K per bug, $250K total program cap
|
|
396
|
+
|
|
397
|
+
### HackerOne — Web Applications
|
|
398
|
+
- **URL**: https://stellar.org/grants-and-funding/bug-bounty
|
|
399
|
+
- **Scope**: SDF web applications, production servers, domains
|
|
400
|
+
- **Disclosure**: 90-day remediation window before public disclosure
|
|
401
|
+
|
|
402
|
+
## Soroban Audit Bank
|
|
403
|
+
|
|
404
|
+
SDF's proactive security program with **$3M+ deployed across 43+ audits**.
|
|
405
|
+
|
|
406
|
+
- **URL**: https://stellar.org/grants-and-funding/soroban-audit-bank
|
|
407
|
+
- **Projects list**: https://stellar.org/audit-bank/projects
|
|
408
|
+
- **Eligibility**: SCF-funded projects (financial protocols, infrastructure, high-traction dApps)
|
|
409
|
+
- **Co-payment**: 5% upfront (refundable if Critical/High/Medium issues remediated within 20 business days)
|
|
410
|
+
- **Follow-up audits**: Triggered at $10M and $100M TVL milestones (includes formal verification and competitive audits)
|
|
411
|
+
- **Preparation**: STRIDE threat modeling framework + Audit Readiness Checklist
|
|
412
|
+
|
|
413
|
+
### Partner Audit Firms
|
|
414
|
+
|
|
415
|
+
| Firm | Specialty |
|
|
416
|
+
|------|-----------|
|
|
417
|
+
| **OtterSec** | Smart contract audits |
|
|
418
|
+
| **Veridise** | Tool-assisted audits, [security checklist](https://veridise.com/blog/audit-insights/building-on-stellar-soroban-grab-this-security-checklist-to-avoid-vulnerabilities/) |
|
|
419
|
+
| **Runtime Verification** | Formal methods, [Komet tool](https://runtimeverification.com/blog/introducing-komet-smart-contract-testing-and-verification-tool-for-soroban-created-by-runtime-verification) |
|
|
420
|
+
| **CoinFabrik** | Static analysis (Scout), manual audits |
|
|
421
|
+
| **QuarksLab** | Security research |
|
|
422
|
+
| **Coinspect** | Security audits |
|
|
423
|
+
| **Certora** | Formal verification ([Sunbeam Prover](https://docs.certora.com/en/latest/docs/sunbeam/index.html)) |
|
|
424
|
+
| **Halborn** | Security assessments |
|
|
425
|
+
| **Zellic** | Blockchain + cryptography research |
|
|
426
|
+
| **Code4rena** | Competitive audit platform |
|
|
427
|
+
|
|
428
|
+
## Security Tooling
|
|
429
|
+
|
|
430
|
+
### Static Analysis
|
|
431
|
+
|
|
432
|
+
#### Scout Soroban (CoinFabrik)
|
|
433
|
+
Open-source vulnerability detector with 23 detectors (critical through enhancement severity).
|
|
434
|
+
- **GitHub**: https://github.com/CoinFabrik/scout-soroban
|
|
435
|
+
- **Install**: `cargo install cargo-scout-audit` → `cargo scout-audit`
|
|
436
|
+
- **Output formats**: HTML, Markdown, JSON, PDF, SARIF (CI/CD integration)
|
|
437
|
+
- **VSCode extension**: [Scout Audit](https://marketplace.visualstudio.com/items?itemName=CoinFabrik.scout-audit)
|
|
438
|
+
- **Key detectors**: `overflow-check`, `unprotected-update-current-contract-wasm`, `set-contract-storage`, `unrestricted-transfer-from`, `divide-before-multiply`, `dos-unbounded-operation`, `unsafe-unwrap`
|
|
439
|
+
|
|
440
|
+
#### OpenZeppelin Security Detectors SDK
|
|
441
|
+
Framework for building custom security detectors for Soroban.
|
|
442
|
+
- **GitHub**: https://github.com/OpenZeppelin/soroban-security-detectors-sdk
|
|
443
|
+
- **Architecture**: `sdk` (core), `detectors` (pre-built), `soroban-scanner` (CLI)
|
|
444
|
+
- **Pre-built detectors**: `auth_missing`, `unchecked_ft_transfer`, improper TTL extension, contract panics, unsafe temporary storage
|
|
445
|
+
- **Extensible**: Load external detector libraries as shared objects
|
|
446
|
+
|
|
447
|
+
### Formal Verification
|
|
448
|
+
|
|
449
|
+
#### Certora Sunbeam Prover
|
|
450
|
+
Purpose-built formal verification for Soroban — first WASM platform supported by Certora.
|
|
451
|
+
- **Docs**: https://docs.certora.com/en/latest/docs/sunbeam/index.html
|
|
452
|
+
- **Spec language**: CVLR (Certora Verification Language for Rust) — Rust macros (`cvlr_assert!`, `cvlr_assume!`, `cvlr_satisfy!`)
|
|
453
|
+
- **Operates at**: WASM bytecode level (eliminates compiler trust assumptions)
|
|
454
|
+
- **Reports**: https://github.com/Certora/SecurityReports
|
|
455
|
+
- **Example**: [Blend V1 verification report](https://www.certora.com/reports/blend-smart-contract-verification-report)
|
|
456
|
+
|
|
457
|
+
#### Runtime Verification — Komet
|
|
458
|
+
Formal verification and testing tool built specifically for Soroban (SCF-funded).
|
|
459
|
+
- **Docs**: https://docs.runtimeverification.com/komet
|
|
460
|
+
- **Repo**: https://github.com/runtimeverification/komet
|
|
461
|
+
- **Spec language**: Rust — property-based tests written in the same language as Soroban contracts
|
|
462
|
+
- **Operates at**: WASM bytecode level via [KWasm semantics](https://github.com/runtimeverification/wasm-semantics) (eliminates compiler trust assumptions)
|
|
463
|
+
- **Features**: Fuzzing, testing, formal verification
|
|
464
|
+
- **Reports**: [RV publications](https://github.com/runtimeverification/publications)
|
|
465
|
+
- **Example**: [TokenOps audit and verification report](https://github.com/runtimeverification/publications/blob/main/reports/smart-contracts/TokenOps.pdf)
|
|
466
|
+
- **Blog**: [Introducing Komet](https://runtimeverification.com/blog/introducing-komet-smart-contract-testing-and-verification-tool-for-soroban-created-by-runtime-verification)
|
|
467
|
+
|
|
468
|
+
### Security Knowledge Base
|
|
469
|
+
|
|
470
|
+
#### Soroban Security Portal
|
|
471
|
+
Community security knowledge base by Inferara (SCF-funded).
|
|
472
|
+
- **URL**: https://sorobansecurity.com
|
|
473
|
+
- **Features**: Searchable audit reports, vulnerability database, best practices
|
|
474
|
+
|
|
475
|
+
### Security Monitoring (Post-Deployment)
|
|
476
|
+
|
|
477
|
+
#### OpenZeppelin Monitor (Stellar alpha)
|
|
478
|
+
Open-source contract monitoring with Stellar support.
|
|
479
|
+
- **Features**: Self-hosted via Docker, Prometheus + Grafana observability
|
|
480
|
+
- **Source**: https://www.openzeppelin.com/news/monitor-and-relayers-are-now-open-source
|
|
481
|
+
|
|
482
|
+
## OpenZeppelin Partnership Overview
|
|
483
|
+
|
|
484
|
+
Strategic partnership highlights include:
|
|
485
|
+
- **40 Auditor Weeks** of dedicated security audits
|
|
486
|
+
- **Stellar Contracts library** (audited, production-ready)
|
|
487
|
+
- **Relayer** (fee-sponsored transactions, Stellar-native)
|
|
488
|
+
- **Monitor** (contract monitoring, Stellar alpha)
|
|
489
|
+
- **Security Detectors SDK** (static analysis framework)
|
|
490
|
+
- **SEP authorship**: SEP-0049 (Upgradeable Contracts), SEP-0050 (NFTs)
|
|
491
|
+
- **Blog**: https://stellar.org/blog/foundation-news/sdf-partners-with-openzeppelin-to-enhance-stellar-smart-contract-development
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Stellar Standards Reference (SEPs & CAPs)
|
|
2
|
+
|
|
3
|
+
## When to use this guide
|
|
4
|
+
Use this when you need:
|
|
5
|
+
- The right SEP/CAP for a feature or integration
|
|
6
|
+
- Interoperability guidance for wallets, anchors, and contracts
|
|
7
|
+
- A fast map from use case to official standards docs
|
|
8
|
+
|
|
9
|
+
## Maintenance note
|
|
10
|
+
Standards status can change quickly.
|
|
11
|
+
Before implementation, verify current status in:
|
|
12
|
+
- SEPs: [stellar-protocol/ecosystem](https://github.com/stellar/stellar-protocol/tree/master/ecosystem)
|
|
13
|
+
- CAPs: [stellar-protocol/core](https://github.com/stellar/stellar-protocol/tree/master/core)
|
|
14
|
+
|
|
15
|
+
Treat this file as a routing map, not a source of final governance/status truth.
|
|
16
|
+
|
|
17
|
+
## High-value SEPs for app developers
|
|
18
|
+
|
|
19
|
+
### Contracts and token interfaces
|
|
20
|
+
- [SEP-0041](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0041.md): Soroban token interface
|
|
21
|
+
- [SEP-0046](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0046.md): Contract metadata in Wasm
|
|
22
|
+
- [SEP-0048](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0048.md): Contract interface specification
|
|
23
|
+
- [SEP-0049](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0049.md): Upgradeable-contract guidance
|
|
24
|
+
- [SEP-0050](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0050.md): NFT standard work
|
|
25
|
+
- [SEP-0055](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0055.md): Contract build verification
|
|
26
|
+
- [SEP-0056](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0056.md): Vault-style tokenized products
|
|
27
|
+
- [SEP-0057](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0057.md): Regulated token patterns (T-REX)
|
|
28
|
+
|
|
29
|
+
### Auth, identity, and metadata
|
|
30
|
+
- [SEP-0010](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md): Web authentication
|
|
31
|
+
- [SEP-0023](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0023.md): StrKey encoding
|
|
32
|
+
- [SEP-0001](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md): `stellar.toml`
|
|
33
|
+
|
|
34
|
+
### Anchor and fiat integration
|
|
35
|
+
- [SEP-0006](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0006.md): Programmatic deposit/withdrawal API
|
|
36
|
+
- [SEP-0024](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0024.md): Hosted interactive anchor flow
|
|
37
|
+
- [SEP-0031](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0031.md): Cross-border payment flow
|
|
38
|
+
- [SEP-0012](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0012.md): KYC data exchange
|
|
39
|
+
|
|
40
|
+
## High-value CAPs for Soroban developers
|
|
41
|
+
|
|
42
|
+
### Soroban foundations
|
|
43
|
+
- [CAP-0046](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0046.md): Soroban overview
|
|
44
|
+
- CAP-0046 subdocuments (`cap-0046-*.md`): runtime, lifecycle, host functions, storage, auth, metering
|
|
45
|
+
|
|
46
|
+
### Frequently used contract capabilities
|
|
47
|
+
- [CAP-0051](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0051.md): secp256r1 verification (passkey-related cryptography)
|
|
48
|
+
- [CAP-0053](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0053.md): TTL extension behavior
|
|
49
|
+
- [CAP-0058](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0058.md): constructors (`__constructor`)
|
|
50
|
+
- [CAP-0059](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0059.md): BLS12-381 primitives
|
|
51
|
+
- [CAP-0067](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0067.md): protocol/runtime improvements including asset/event model changes
|
|
52
|
+
|
|
53
|
+
### Newer and draft crypto/features
|
|
54
|
+
- [CAP-0074](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0074.md): BN254 host functions proposal
|
|
55
|
+
- [CAP-0075](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0075.md): Poseidon/Poseidon2 proposal
|
|
56
|
+
- [CAP-0079](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0079.md): muxed-address strkey conversion proposal
|
|
57
|
+
|
|
58
|
+
Use the CAP preamble status fields as the source of truth for implementation readiness.
|
|
59
|
+
|
|
60
|
+
## Quick mapping by use case
|
|
61
|
+
|
|
62
|
+
### I am building a fungible token
|
|
63
|
+
1. Start with SEP-0041 interface expectations.
|
|
64
|
+
2. Prefer Stellar Assets + SAC interop unless custom logic is required.
|
|
65
|
+
3. If regulated, review SEP-0057 patterns.
|
|
66
|
+
|
|
67
|
+
### I need upgrade-safe contracts
|
|
68
|
+
1. Read SEP-0049 guidance for upgrade process design.
|
|
69
|
+
2. Use CAP-0058 constructors for atomic initialization where protocol support exists.
|
|
70
|
+
3. Add migration/versioning strategy before deploying upgradeable contracts.
|
|
71
|
+
|
|
72
|
+
### I am building a smart-wallet flow
|
|
73
|
+
1. Use SEP-0010 for web authentication flows.
|
|
74
|
+
2. Review CAP-0051 for passkey-related cryptographic primitives.
|
|
75
|
+
3. Align wallet UX and signing payloads with current SDK guidance.
|
|
76
|
+
|
|
77
|
+
### I need anchor integration for fiat rails
|
|
78
|
+
1. SEP-0006 for API-first flows.
|
|
79
|
+
2. SEP-0024 for hosted interactive rails.
|
|
80
|
+
3. SEP-0031 when supporting payment corridors.
|
|
81
|
+
4. SEP-0012 for KYC data requirements.
|
|
82
|
+
|
|
83
|
+
## Practical workflow for AI agents
|
|
84
|
+
- Step 1: Identify feature category (token, wallet auth, anchor, upgradeability).
|
|
85
|
+
- Step 2: Link user to the 1-3 primary SEP/CAP docs.
|
|
86
|
+
- Step 3: Check status/acceptance in the source repo before asserting support.
|
|
87
|
+
- Step 4: Implement only what is active on the target network/protocol.
|
|
88
|
+
- Step 5: Document dependencies on draft standards explicitly.
|
|
89
|
+
|
|
90
|
+
## Related docs
|
|
91
|
+
- Contract implementation details: `contracts-soroban.md`
|
|
92
|
+
- Advanced architecture guidance: `advanced-patterns.md`
|
|
93
|
+
- RPC and data access: `api-rpc-horizon.md`
|
|
94
|
+
- Security considerations: `security.md`
|