Skip to content

Security: TogetherCrew/snet-reputation-docs

Security

SECURITY.md

Reputation System Security

Related Documentation:

Table of Contents

  1. Authentication
  2. Data Protection
  3. Access Control
  4. Security Headers
  5. CORS Policy
  6. Audit Logging
  7. Security Monitoring

1. Authentication

JWT Authentication

The system uses JWT tokens issued by the DDI platform for both:

  • User authentication (staff members)
  • Service authentication (machine-to-machine)

Required Claims

{
  "sub": "staff_id_123", // or "service_id_123" for m2m
  "iss": "https://ddi.platform",
  "aud": ["reputation-system"],
  "exp": 1625097600,
  "permissions": ["snapshot:create", "snapshot:execute"],
  "type": "user" // or "service" for m2m
}

Token Management

  • Access tokens expire after 1 hour
  • Refresh tokens valid for 30 days
  • Rotate refresh tokens on use
  • Implement token revocation
  • Monitor token usage for suspicious patterns

Security Benefits

  • Single authentication mechanism for all clients
  • Fine-grained permission control via JWT claims
  • Token-based rate limiting and monitoring
  • Enhanced audit trails with client context
  • Defense in depth with token validation

2. Data Protection

Sensitive Data Handling

  • Encrypt sensitive data at rest
  • Use TLS 1.3 for all communications
  • Implement request signing for critical operations
  • Log security events with proper masking

Onchain Data

  • Merkle tree for efficient verification
  • Zero-knowledge proofs for privacy
  • Smart contract access control
  • Immutable commitment records

3. Access Control

Permission Levels

  • snapshot:create - Create new snapshots
  • snapshot:execute - Run snapshot calculations
  • snapshot:commit - Commit results onchain
  • snapshot:read - View snapshot data
  • score:read - View score data

Role-Based Access

  • Admin: Full access
  • Operator: Create and execute snapshots
  • Viewer: Read-only access
  • Service: Machine-to-machine access

4. Security Headers

Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block

5. CORS Policy

Access-Control-Allow-Origin: https://{HOST}
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, X-Request-ID
Access-Control-Max-Age: 86400

6. Audit Logging

Required Logs

  • Authentication attempts
  • Token usage and revocation
  • Snapshot operations
  • Onchain commitments
  • Score verifications
  • Permission changes

Log Format

{
  "timestamp": "2025-06-01T12:00:00Z",
  "level": "INFO",
  "request_id": "uuid",
  "user_id": "staff_123",
  "action": "snapshot:create",
  "resource_id": "snap_123",
  "ip_address": "1.2.3.4",
  "user_agent": "Mozilla/5.0...",
  "status": "success"
}

7. Security Monitoring

Metrics

  • Failed authentication attempts
  • Token usage patterns
  • Rate limit hits
  • Suspicious IP addresses
  • Unusual access patterns

Alerts

  • Multiple failed logins
  • Unusual token usage
  • Rate limit breaches
  • Permission changes
  • Onchain commitment failures

There aren’t any published security advisories