Skip to content
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bb7bcba
docs: add comprehensive escrow onboarding documentation
claude Nov 19, 2025
7e2ff36
docs: add implementation phases guide for escrow system
claude Nov 19, 2025
c386021
feat(escrow): Phase 1 - add database schema for escrow system
claude Nov 19, 2025
690e03a
style: apply prettier formatting to EscrowTypes.ts
claude Nov 19, 2025
fa4f4db
style: apply prettier auto-formatting to existing files
claude Nov 19, 2025
e3681f4
feat(escrow): Phase 2 - implement GCR escrow operations
claude Nov 19, 2025
985462b
docs: add SDK repository implementation guide
claude Nov 19, 2025
0da13e7
docs: update escrow SDK implementation status
Nov 19, 2025
a23cecc
bumped sdk
Nov 19, 2025
647fa33
docs: refactor escrow documentation for clarity
claude Nov 19, 2025
a490a68
feat(escrow): Phase 4 - implement RPC endpoints for escrow queries
claude Nov 19, 2025
7711024
fix(escrow): auto-fix code quality issues
claude Nov 19, 2025
5a37ebb
fix(escrow): resolve race condition, add index, optimize N+1 queries
claude Nov 19, 2025
dda1ddb
fix(escrow): resolve 7 critical issues from CodeRabbit review
Nov 20, 2025
63a8d05
fix(escrow): resolve 4 critical issues from second CodeRabbit review
Nov 20, 2025
121a7a8
fix(escrow): resolve 7 critical security and robustness issues
Nov 20, 2025
88a6326
chore: configure ESLint to ignore test files and ts-comment
Nov 20, 2025
04989f3
fixed types errors
Nov 21, 2025
d92823a
memories
Nov 21, 2025
e78e9a0
applied fixes to avoid funds locks and race conditions
Nov 21, 2025
4643b5c
updated docs and memories
Nov 21, 2025
db887c7
fix: comprehensive escrow system security hardening (18 bugs fixed)
Nov 22, 2025
b80fed9
fixed 4 issues
Nov 22, 2025
f525d70
Update src/libs/network/middleware/rateLimiter.ts
tcsenpai Nov 22, 2025
e02ec71
Update src/libs/network/endpointHandlers.ts
tcsenpai Nov 22, 2025
6ea1773
Update EscrowOnboarding/IMPLEMENTATION_PHASES.md
tcsenpai Nov 22, 2025
9fda71a
Update SECURITY_HARDENING_REPORT.md
tcsenpai Nov 22, 2025
fdcffd9
Update EscrowOnboarding/IMPLEMENTATION_PHASES.md
tcsenpai Nov 22, 2025
89702fc
feat(escrow): add Discord platform support
Nov 22, 2025
cd15186
feat(escrow): complete Discord platform support in routines
Nov 22, 2025
529ffe5
feat(escrow): implement proper rollback behavior for multi-edit trans…
Nov 22, 2025
bfff628
refactor(escrow): use canonical SUPPORTED_PLATFORMS constant
Nov 22, 2025
675ad51
refactor(escrow): remove inline MAX_DEPOSITS_PER_ESCROW declaration
Nov 22, 2025
def7bcf
fix(escrow): defer state mutations until after simulate flag check
Nov 23, 2025
d5cf927
fix(rate-limiter): use while loop for burst-resistant eviction
Nov 23, 2025
7ac3bfa
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai Nov 23, 2025
297213f
fix(escrow): prevent TOCTOU race condition in flagged account check
Nov 23, 2025
ee18e73
Merge remote-tracking branch 'refs/remotes/origin/claude/testnet-wall…
Nov 23, 2025
22f5710
fix(escrow): prevent deadlocks in rollback operations
Nov 23, 2025
3cbf449
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai Nov 23, 2025
b777c89
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai Nov 23, 2025
ad11e65
Merge remote-tracking branch 'refs/remotes/origin/claude/testnet-wall…
Nov 23, 2025
b6c2d33
ignores
Dec 5, 2025
083b49e
refactor(escrow): reduce cognitive complexity in applyEscrowDeposit
Dec 5, 2025
1787a6e
refactor(escrow): reduce cognitive complexity in handleGetSentEscrows
Dec 5, 2025
1c5c8ba
beads init
Dec 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist
.vscode
.env
postgres_*
aptos_examples_ts
aptos_examples_ts
local_tests
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
"@typescript-eslint/ban-types": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/ban-ts-comment": ["off"],
"switch-colon-spacing": ["error", { after: true, before: false }],
"no-extra-semi": "error",
"comma-dangle": ["error", "always-multiline"],
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,9 @@ http-capture-1762008909.pcap
http-traffic.json
PR_REVIEW_FINAL.md
REVIEWER_QUESTIONS_ANSWERED.md
.
src/features/zk
PR_REVIEW_RAW.md
PR_REVIEW.md
BUGS_AND_SECURITY_REPORT.md
PR_REVIEW_COMPREHENSIVE.md
113 changes: 113 additions & 0 deletions .serena/memories/escrow_security_patterns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Escrow Security Patterns and Best Practices

## Critical Security Validations

### Input Validation Pattern
All escrow operations must validate:
1. **Length limits**: Platform ≤20 chars, Username ≤100 chars
2. **Unicode normalization**: NFKC normalization to prevent collision attacks
3. **Delimiter protection**: Prevent `:` in platform/username fields
4. **Non-empty validation**: Require trimmed non-empty strings

### Balance Protection Pattern
```typescript
const MAX_BALANCE = BigInt("1000000000000000000000") // 1 sextillion DEM

// Always check overflow before applying
const newBalance = previousBalance + BigInt(amount)
if (newBalance > MAX_BALANCE) {
// Reject operation
}
```

### Time-Based Validation Pattern
```typescript
const MIN_EXPIRY_DAYS = 1
const MAX_EXPIRY_DAYS = 365 // Prevent indefinite fund locking

// Validate expiry on deposit creation
if (requestedExpiry < MIN_EXPIRY_DAYS || requestedExpiry > MAX_EXPIRY_DAYS) {
// Reject operation
}
```

### Access Control Pattern
```typescript
// Always check flagged status before allowing fund operations
if (account.flagged) {
return {
success: false,
message: "Account is flagged and cannot perform this operation"
}
}
```

## Attack Vectors Mitigated

### 1. Unicode Collision Attack
**Attack**: Different Unicode strings generating same hash
**Defense**: NFKC normalization + delimiter validation
**Example**: `alice` vs `alice` (fullwidth) → normalized to same value

### 2. Fund Locking Attack
**Attack**: Creating escrow with distant future expiry
**Defense**: 365-day maximum expiry validation
**Impact**: Prevents permanent fund locks

### 3. Balance Overflow Attack
**Attack**: Deposit amounts causing integer overflow
**Defense**: BigInt arithmetic + MAX_BALANCE check
**Impact**: Prevents theft via wrapping

### 4. DoS via Large Input
**Attack**: Submitting 10MB usernames to exhaust SHA3 computation
**Defense**: Length limits (20/100 chars)
**Impact**: Protects network from computational DoS

### 5. Flagged Account Bypass
**Attack**: Banned accounts claiming escrow funds
**Defense**: Flagged status check before claim
**Impact**: Enforces access control policies

## Code Review Checklist

When reviewing escrow-related code, verify:
- [ ] All string inputs have length validation
- [ ] Unicode normalization applied to user-provided identifiers
- [ ] BigInt used for all balance arithmetic
- [ ] Overflow checks before balance updates
- [ ] Time-based validations have reasonable bounds
- [ ] Flagged account checks before sensitive operations
- [ ] No delimiter characters allowed in structured identifiers

## Constants Reference

```typescript
// Escrow limits
const MIN_EXPIRY_DAYS = 1
const MAX_EXPIRY_DAYS = 365
const MS_PER_DAY = 24 * 60 * 60 * 1000
const MAX_BALANCE = BigInt("1000000000000000000000")
const MAX_PLATFORM_LENGTH = 20
const MAX_USERNAME_LENGTH = 100

// Rate limits
escrow_deposit: { maxRequests: 10, windowMs: 60000 }
escrow_claim: { maxRequests: 5, windowMs: 60000 }
escrow_refund: { maxRequests: 5, windowMs: 60000 }
```

## Testing Recommendations

### Security Test Cases
1. **Unicode attacks**: Submit fullwidth, combining marks, homographs
2. **Overflow attacks**: Test max values, boundary conditions
3. **DoS attacks**: Submit maximum allowed lengths, measure performance
4. **Time attacks**: Test min/max expiry bounds, expired escrows
5. **Access control**: Verify flagged accounts rejected

### Performance Benchmarks
- Hash computation time with MAX_USERNAME_LENGTH input
- Database query latency with GIN indexes
- Rate limiter eviction performance at 100K IPs
- Point calculation latency (should be 4x faster)
70 changes: 0 additions & 70 deletions .serena/memories/pr_review_analysis_complete.md

This file was deleted.

73 changes: 0 additions & 73 deletions .serena/memories/pr_review_corrected_analysis.md

This file was deleted.

38 changes: 0 additions & 38 deletions .serena/memories/pr_review_import_fix_completed.md

This file was deleted.

70 changes: 0 additions & 70 deletions .serena/memories/pr_review_point_system_fixes_completed.md

This file was deleted.

Loading