security-sensitive-path-instrumenter

Instruments authentication, authorization, and input-handling code paths to monitor security-relevant events and states at runtime. Use this skill when developers need to add security monitoring and logging to their code, including tracking authentication attempts (login/logout), authorization decisions (access control checks), input validation failures, session management events, and other security-critical operations. Supports Python, JavaScript/TypeScript, and Java with structured logging patterns. Triggers when users ask to add security instrumentation, monitor security events, log authentication/authorization, track security-sensitive operations, or add security observability to their codebase.

arabelatso/skills-4-se3 installsApache-2.0Synced Aug 22

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: security-sensitive-path-instrumenter
description: Instruments authentication, authorization, and input-handling code paths to monitor security-relevant events and states at runtime. Use this skill when developers need to add security monitoring and logging to their code, including tracking authentication attempts (login/logout), authorization decisions (access control checks), input validation failures, session management events, and other security-critical operations. Supports Python, JavaScript/TypeScript, and Java with structured logging patterns. Triggers when users ask to add security instrumentation, monitor security events, log authentication/authorization, track security-sensitive operations, or add security observability to their codebase.
license: Apache-2.0
---

# Security-Sensitive Path Instrumenter

Add structured logging instrumentation to security-critical code paths for runtime monitoring of authentication, authorization, input validation, session management, and other security-relevant events.

## Workflow

1. **Identify security-sensitive code paths** - Locate authentication, authorization, input validation, or session management code that needs instrumentation

2. **Determine event types** - Classify the security events to monitor (see [security_events.md](references/security_events.md) for taxonomy)

3. **Review best practices** - Check [best_practices.md](references/best_practices.md) for what to log and what to avoid (never log passwords, secrets, or sensitive PII)

4. **Select language patterns** - Use [language_patterns.md](references/language_patterns.md) for language-specific instrumentation code (Python, JavaScript/TypeScript, Java)

5. **Add instrumentation** - Insert structured logging calls at key decision points:
   - Before and after authentication attempts
   - At authorization check points
   - When validation fails
   - During session lifecycle events

6. **Include context** - Log relevant data points:
   - User identifier
   - Timestamp (automatically added)
   - IP address
   - Resource accessed
   - Success/failure status
   - Failure reasons

7. **Verify instrumentation** - Ensure:
   - No sensitive data (passwords, tokens, secrets) is logged
   - Structured format (JSON) is used for machine parsing
   - Appropriate log levels are set
   - Performance impact is minimal

## Quick Reference

### Event Categories

- **Authentication**: Login attempts, logout, password changes, MFA, token validation
- **Authorization**: Access control decisions, permission checks, RBAC evaluations
- **Input Validation**: Validation failures, injection detection, format violations
- **Session Management**: Session creation/expiration, IP changes, hijacking detection
- **Sensitive Data Access**: PII access, financial data, encryption key usage
- **Configuration Changes**: Permission changes, role assignments, security policy updates

### Common Patterns

**Authentication (Python/Flask)**:
```python
log_security_event(
    event_type='authentication_attempt',
    username=username,
    ip_address=request.remote_addr
)
```

**Authorization (JavaScript/Express)**:
```typescript
logSecurityEvent('authorization_check', {
  user_id: user.id,
  resource: resourceId,
  permission: requiredPermission,
  decision: hasPermission ? 'granted' : 'denied'
});
```

**Validation (Java/Spring)**:
```java
Map<String, Object> data = new HashMap<>();
data.put("user_id", user.getId());
data.put("errors", validationErrors);
SecurityLogger.logSecurityEvent("validation_failure", data);
```

## Helper Script

Use `scripts/generate_instrumentation.py` to generate code snippets:

```bash
# Generate Python authentication instrumentation
python scripts/generate_instrumentation.py python authentication

# Generate JavaScript authorization instrumentation
python scripts/generate_instrumentation.py javascript authorization

# Generate Java validation instrumentation
python scripts/generate_instrumentation.py java validation
```

## Important Reminders

**Never log**:
- Passwords (plaintext or hashed)
- API keys or secrets
- Full session tokens
- Credit card numbers
- Social Security numbers
- Encryption keys

**Always log**:
- Event type and timestamp
- User identifier (when available)
- Success/failure status
- IP address (consider GDPR)
- Resource accessed
- Action performed

**Use structured logging** (JSON format) for machine parsing and analysis.

More Security skills

azure-cost

microsoft/azure-skills

Azure cost management: query costs, forecast spending, optimize to reduce waste. WHEN: \"Azure costs\", \"Azure bill\", \"cost breakdown\", \"how much am I spending\", \"forecast spending\", \"optimize costs\", \"reduce spending\", \"orphaned resources\", \"rightsize VMs\", \"cost spike\", \"reduce storage costs\", \"AKS cost\". DO NOT USE FOR: deploying resources, provisioning, diagnostics, or security audits.

355.6k

entra-app-registration

microsoft/azure-skills

Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.

318.9k

azure-messaging

microsoft/azure-skills

Troubleshoot and resolve issues with Azure Messaging SDKs for Event Hubs and Service Bus. Covers connection failures, authentication errors, message processing issues, and SDK configuration problems. WHEN: event hub SDK error, service bus SDK issue, messaging connection failure, AMQP error, event processor host issue, message lock lost, message lock expired, lock renewal, lock renewal batch, send timeout, receiver disconnected, SDK troubleshooting, azure messaging SDK, event hub consumer, service bus queue issue, topic subscription error, enable logging event hub, service bus logging, eventhub python, servicebus java, eventhub javascript, servicebus dotnet, event hub checkpoint, event hub not receiving messages, service bus dead letter, batch processing lock, session lock expired, idle timeout, connection inactive, link detach, slow reconnect, session error, duplicate events, offset reset, receive batch.

310.3k

← All Security skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY