agentleFS
exchanetexchanet/method_enterprise_builder_planning/.cursor/rules/ENTERPRISE_SECURITY.md

method_enterprise_builder_planning / rules

Cursor rule2 starsChanged 9 months agoMITView on GitHub

Reference guide for security-by-design practices in enterprise systems. Every module must complete this checklist before delivery. Security in enterprise systems is never a phase — it is a continuous property integrated at every layer: Apply STRIDE analysis to every module and every API endpoint. Use when: resource ownership matters (user can only edit their own resources), dynamic context (time-based access, location-based), data classification levels.

The file

We split this ENTERPRISE_SECURITY.md into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when: resource ownership matters (user can only edit their own resources), dynamic context (time-based access, location-based), data …

    line 95
  2. Distinctive:

    Every service account has only the permissions it needs for its specific function

    line 107
  3. Distinctive:

    Every enterprise system MUST audit:

    line 186
  4. Distinctive:

    Search: queryable by actor, resource, time range, action

    line 241
  5. Distinctive:

    Before delivering any API or web interface, verify:

    line 248

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
ENTERPRISE_SECURITY.md

ENTERPRISE_SECURITY

Reference guide for security-by-design practices in enterprise systems. Every module must complete this checklist before delivery.


Security-First Principle

Security in enterprise systems is never a phase — it is a continuous property integrated at every layer:

THREAT MODEL (before architecture) → SECURE DESIGN (during architecture)
→ SECURE CODE (during implementation) → SECURITY TESTS (during testing)
→ SECURITY AUDIT (before delivery) → RUNTIME MONITORING (after delivery)

STRIDE Threat Model

Apply STRIDE analysis to every module and every API endpoint.

STRIDE categories

ThreatDefinitionControl mechanism
SpoofingAttacker impersonates a user or systemAuthentication (MFA, certificates)
TamperingAttacker modifies data in transit or at restIntegrity checks, signatures, HMAC
RepudiationActor denies performing an actionAudit logs, digital signatures
Information DisclosureSensitive data exposed to unauthorized partiesEncryption, access controls, data masking
Denial of ServiceSystem made unavailableRate limiting, circuit breakers, auto-scaling
Elevation of PrivilegeAttacker gains higher permissionsRBAC, least privilege, input validation

STRIDE analysis template

## STRIDE Analysis: [Module / Endpoint Name]

| Threat | Attack Scenario | Current Control | Residual Risk | Status |
|---|---|---|---|---|
| Spoofing | JWT token theft via XSS | HttpOnly cookies, Content-Security-Policy | Low | Mitigated |
| Tampering | Modify request body to escalate price | Input validation + HMAC signature | Low | Mitigated |
| Repudiation | Admin denies deleting user | Immutable audit log with user ID | Low | Mitigated |
| Info Disclosure | SQL error exposes schema | Generic error messages, structured logging | Low | Mitigated |
| DoS | Flood login endpoint | Rate limiting 10 req/min per IP | Medium | Accepted |
| Elevation | Horizontal privilege escalation | Resource ownership check per request | Low | Mitigated |

Authentication Standards

Minimum requirements for enterprise systems

Authentication scheme:
├── Public APIs (external users):  OAuth 2.0 + PKCE or SAML 2.0
├── Internal service-to-service:   mTLS or signed JWTs (RS256/ES256)
├── Admin interfaces:              MFA mandatory (TOTP or hardware key)
└── Machine accounts:              Client credentials + IP allowlist

Token requirements:
├── Algorithm: RS256 or ES256 (never HS256 for multi-service)
├── Access token expiry: 15 minutes maximum
├── Refresh token expiry: 7 days (rotated on use)
├── Token storage: HttpOnly + Secure + SameSite=Strict cookies
└── Token revocation: Blocklist or short expiry + refresh rotation

Multi-Factor Authentication (MFA)

  • MFA mandatory for: admin accounts, finance operations, PII access
  • Supported methods: TOTP (RFC 6238), WebAuthn/FIDO2, SMS (last resort)
  • Recovery codes: generated at enrollment, stored hashed (bcrypt), single use
  • Brute-force protection: exponential backoff + account lockout after 10 failures

Authorization Model

RBAC (Role-Based Access Control) — Default model

## Permission Matrix Template

| Role | Resource | Create | Read | Update | Delete | Export |
|---|---|---|---|---|---|---|
| admin | users | ✓ | ✓ | ✓ | ✓ | ✓ |
| manager | users | ✗ | ✓ | ✓ | ✗ | ✓ |
| viewer | users | ✗ | ✓ | ✗ | ✗ | ✗ |

ABAC (Attribute-Based Access Control) — When RBAC is insufficient

Use when: resource ownership matters (user can only edit their own resources), dynamic context (time-based access, location-based), data classification levels.

Policy rule syntax:
ALLOW action=READ on resource=document
  IF user.department == document.department
  AND document.classification IN user.clearance_levels
  AND current_time BETWEEN 08:00 AND 20:00

Least Privilege enforcement

  • Every service account has only the permissions it needs for its specific function
  • Permissions reviewed quarterly (access recertification)
  • Unused permissions revoked after 90 days of inactivity
  • Privileged access (admin) requires just-in-time (JIT) provisioning

Data Protection

Data Classification

ClassDescriptionExamplesControls required
PublicNo harm if disclosedMarketing contentNone beyond integrity
InternalNot for external disclosureInternal docs, configAccess control
ConfidentialBusiness sensitiveBusiness plans, contractsEncryption + access control
RestrictedRegulated or high-impactPII, financial data, healthEncryption + audit + RBAC + DLP

Encryption standards

At rest:
├── Databases: AES-256-GCM (transparent encryption at storage level)
├── File storage: AES-256-GCM with envelope encryption (data key + master key)
├── Backups: Same as primary data
└── Key management: AWS KMS / Azure Key Vault / HashiCorp Vault

In transit:
├── External: TLS 1.3 minimum (TLS 1.2 acceptable with strong ciphers)
├── Internal: TLS 1.2+ or mTLS for service-to-service
├── Cipher suites: ECDHE+AESGCM (disable RC4, DES, 3DES, export ciphers)
└── Certificate rotation: automated, 90-day maximum validity

PII Handling

  • Identify all PII fields at schema design time (GDPR Article 4)
  • PII fields logged: never (mask or exclude from all log output)
  • PII in responses: include only fields needed by the consumer (field filtering)
  • PII retention: document retention period per data type, automated deletion
  • Right to erasure: soft delete + anonymization pipeline, not hard delete

Input Validation and Output Sanitization

Input validation — non-negotiable rules

Every input MUST be validated for:
├── Type (string, integer, boolean, UUID, date...)
├── Format (regex, enum, range, length)
├── Business rules (ownership, state machine transitions)
└── Security rules (SQL injection, XSS, path traversal, command injection)

Validation strategy:
├── Allowlist (whitelist) over Denylist (blacklist)
├── Validate at the boundary (API layer), re-validate at domain layer
├── Reject invalid input with 400 Bad Request + structured error
└── Never trust client-supplied data for server-side decisions

Output sanitization

Every output MUST be sanitized for:
├── SQL output: parameterized queries only (never string concatenation)
├── HTML output: escape or use safe templating (never innerHTML with user data)
├── JSON output: validate schema matches contract (no internal fields leaked)
├── Error messages: generic to users, detailed in structured logs
└── File paths: canonicalize and validate against allowed base paths

Audit Trail Requirements

Auditable events (minimum set)

Every enterprise system MUST audit:

Authentication events:
├── Login (success and failure, with IP + user agent)
├── Logout
├── Password change / reset
├── MFA enable/disable
└── Token refresh

Authorization events:
├── Permission denied
├── Role assignment / removal
└── Privilege escalation

Data events:
├── Create (with full payload snapshot)
├── Update (with before/after diff)
├── Delete (with payload snapshot)
└── Export / Download of sensitive data

Administrative events:
├── User account create / disable / delete
├── Configuration change
└── Security policy change

Audit log schema

interface AuditEvent {
  id: string;              // UUID v4
  timestamp: string;       // ISO 8601, UTC
  actor: {
    id: string;            // User or service ID
    type: 'user' | 'service' | 'system';
    ip?: string;
    userAgent?: string;
  };
  action: string;          // verb:resource (e.g., "create:user")
  resource: {
    type: string;          // Resource type
    id: string;            // Resource ID
    tenantId?: string;     // Multi-tenant context
  };
  outcome: 'success' | 'failure' | 'error';
  metadata?: Record<string, unknown>; // Before/after state, error details
}

Audit log storage requirements

  • Append-only (no updates or deletes possible)
  • Tamper-evident (HMAC chain or write-once storage)
  • Retention: minimum 1 year hot, 7 years archive (varies by regulation)
  • Search: queryable by actor, resource, time range, action
  • Access: restricted to compliance/security team + automated systems

OWASP Top 10 Checklist (per release)

Before delivering any API or web interface, verify:

A01 Broken Access Control       → [ ] RBAC enforced on every endpoint
A02 Cryptographic Failures      → [ ] All sensitive data encrypted
A03 Injection                   → [ ] All queries parameterized
A04 Insecure Design             → [ ] Threat model completed
A05 Security Misconfiguration   → [ ] Default credentials removed, debug off
A06 Vulnerable Components       → [ ] Dependencies scanned (Dependabot / Snyk)
A07 Auth Failures               → [ ] Account lockout, secure sessions
A08 Software Integrity Failures → [ ] CI/CD pipeline integrity verified
A09 Security Logging Failures   → [ ] Audit log implemented
A10 SSRF                        → [ ] Outbound URL validation enforced

Secrets Management

NEVER:
- Hardcode secrets in source code
- Store secrets in environment variable files committed to git
- Log secrets or tokens at any log level
- Transmit secrets in URL query parameters

ALWAYS:
- Store secrets in a secrets manager (AWS Secrets Manager, Vault, Azure Key Vault)
- Inject secrets at runtime via environment injection or secrets sidecar
- Rotate secrets regularly (API keys: 90 days, DB passwords: 180 days)
- Use different secrets per environment (dev / staging / production)
- Scan commits for secrets (git-secrets, detect-secrets, truffleHog)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.