Skip to content

Commit 83342f5

Browse files
authored
Add SECURITY.md
1 parent 530700b commit 83342f5

1 file changed

Lines changed: 114 additions & 0 deletions

File tree

SECURITY.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Security Policy
2+
3+
## Reporting a Vulnerability
4+
5+
We take security vulnerabilities seriously. If you discover a security issue, please report it responsibly.
6+
7+
### How to Report
8+
9+
**DO NOT** open a public GitHub issue for security vulnerabilities.
10+
11+
Instead, please report security issues via one of these methods:
12+
13+
1. **Email**: Send details to the maintainers (check `pyproject.toml` for contact info)
14+
2. **GitHub Security Advisories**: Use the [private vulnerability reporting feature](https://github.com/langstruct-ai/langstruct/security/advisories/new)
15+
16+
### What to Include
17+
18+
Please provide:
19+
20+
- Description of the vulnerability
21+
- Steps to reproduce the issue
22+
- Potential impact
23+
- Suggested fix (if you have one)
24+
25+
## Security Best Practices
26+
27+
When using LangStruct:
28+
29+
### API Key Management
30+
31+
- **Never commit API keys** to version control
32+
- Use environment variables for all credentials
33+
- Rotate API keys regularly
34+
- Use separate keys for development/production
35+
36+
```python
37+
# ✅ GOOD: Use environment variables
38+
import os
39+
extractor = LangStruct(schema=MySchema) # Reads from env vars
40+
41+
# ❌ BAD: Hardcoded keys
42+
extractor = LangStruct(schema=MySchema, api_key="sk-...")
43+
```
44+
45+
### Input Validation
46+
47+
- **Sanitize user input** before extraction
48+
- Set reasonable limits on text length
49+
- Validate extraction results before using them
50+
- Be cautious with user-provided schemas or examples
51+
52+
### LLM Provider Security
53+
54+
- Review your LLM provider's security policies
55+
- Understand data retention policies
56+
- Use appropriate models for sensitive data
57+
- Consider local models (Ollama) for highly sensitive content
58+
59+
### Production Deployment
60+
61+
- Use rate limiting to prevent abuse
62+
- Monitor API usage and costs
63+
- Implement proper error handling
64+
- Don't expose raw LLM outputs to end users without validation
65+
- Log extractions for audit trails (without logging sensitive data)
66+
67+
### Dependencies
68+
69+
- Keep LangStruct and dependencies updated
70+
- Review security advisories for DSPy and other dependencies
71+
- Use `pip-audit` or similar tools to scan for vulnerable packages
72+
73+
```bash
74+
# Check for vulnerabilities
75+
pip install pip-audit
76+
pip-audit
77+
```
78+
79+
## Known Security Considerations
80+
81+
### Prompt Injection
82+
83+
Like all LLM-based systems, LangStruct is potentially vulnerable to prompt injection attacks. Mitigations:
84+
85+
- Validate and sanitize all user inputs
86+
- Use structured outputs (Pydantic schemas) to constrain results
87+
- Implement output validation
88+
- Consider using separate models for untrusted content
89+
90+
### Data Privacy
91+
92+
- LangStruct sends text to LLM providers for processing
93+
- Text may be logged by providers (depending on their policies)
94+
- For sensitive data:
95+
- Use providers with strong privacy guarantees
96+
- Consider local/on-premise models (Ollama, vLLM)
97+
- Implement PII redaction before extraction
98+
- Review provider data retention policies
99+
100+
### Supply Chain
101+
102+
- LangStruct depends on DSPy, LiteLLM, and Pydantic
103+
- We monitor dependencies for security issues
104+
- Pin your dependencies in production
105+
- Verify package signatures when possible
106+
107+
## Contact
108+
109+
For security-related questions that aren't vulnerabilities:
110+
111+
- Open a discussion on GitHub Discussions
112+
- Check existing documentation and issues first
113+
114+
Thank you for helping keep LangStruct secure!

0 commit comments

Comments
 (0)