Security Policies
Policies define how KoreShield detects and responds to security threats. Usesensitivity to tune detection strictness and default_action to decide what happens when a threat is detected.
Core Policy Settings
Configure security policies in thesecurity section of your config.yaml:
Configuration Parameters
Detection sensitivity level. Controls how strict threat detection is.Options:
low- Require higher confidence to flag contentmedium- Balanced for most production usehigh- Strict detection with fewer false negatives
Default action when a threat is detected.Options:
allow- Permit traffic without restrictionswarn- Allow but log as a security eventblock- Reject requests that violate policy
Enable input sanitization to remove potentially harmful content
Enable threat detection using the detection engine
Enable policy enforcement based on detected threats
Sensitivity Levels
Low Sensitivity
Best for development or testing environments where you want to minimize false positives:Low sensitivity requires higher confidence scores to flag content as malicious. This may miss some attacks but reduces false positives.
Medium Sensitivity
Recommended for most production deployments with balanced detection:Medium sensitivity provides a good balance between catching real threats and avoiding false positives.
High Sensitivity
For high-security environments where you want maximum protection:Threat Actions
Allow
Permit all traffic without restrictions. Use only in development:Warn
Allow traffic but log security events for monitoring:Warn mode is useful during initial deployment to understand threat patterns before enforcing blocks.
Block
Reject requests that violate security policies (recommended for production):Custom Rules and Lists
KoreShield supports custom detection rules to reduce false positives or block known risks:How do custom rules work?
How do custom rules work?
Custom rules are defined using the detection engine DSL (Domain-Specific Language). They allow you to:
- Define custom attack patterns
- Create allowlists for known safe patterns
- Build blocklists for known malicious content
- Override default detection behavior
When should I use allowlists?
When should I use allowlists?
Use allowlists to reduce false positives:
- Legitimate patterns flagged incorrectly
- Known safe API calls or queries
- Internal testing patterns
- Trusted user behaviors
When should I use blocklists?
When should I use blocklists?
Use blocklists for known threats:
- Previously identified attack patterns
- Known malicious payloads
- Banned user agents or IP ranges
- Compliance requirements
Recommended Configurations
Development Environment
Staging Environment
Production Environment
Monitoring and Tuning
Review Security Events
Monitor logs to understand threat patterns:Adjust Based on Metrics
Frequently Asked Questions
What happens when a request is blocked?
What happens when a request is blocked?
Blocked requests receive an HTTP 403 Forbidden response with a security message. The event is logged with details about the detected threat for monitoring and analysis.
Can I set different policies for different endpoints?
Can I set different policies for different endpoints?
Currently, KoreShield applies a global policy. Endpoint-specific policies are planned for future releases. Use custom rules in the detection engine for targeted behavior.
How do I test my policy configuration?
How do I test my policy configuration?
Use test payloads with known attack patterns to verify detection:
- Set
default_action: warntemporarily - Send test requests with injection attempts
- Check logs for detection events
- Verify sanitization is working
- Switch back to
blockmode
What's the performance impact of high sensitivity?
What's the performance impact of high sensitivity?
High sensitivity performs more thorough checks, which may add 10-50ms latency per request. Monitor your
/metrics endpoint to track actual performance impact.Related Documentation
Attack Detection
Learn about detection patterns and custom rules
General Settings
Configure logging, providers, and monitoring
Production Checklist
Pre-deployment security checklist
Monitoring
Monitor security events and metrics