traylinx-auth-client
Version:
Enterprise-grade authentication client with Agent-to-Agent (A2A) Protocol support for Traylinx Sentinel API and agent-to-agent communication
395 lines (303 loc) • 11.9 kB
Markdown
# Security Policy
## Supported Versions
We actively support the following versions of TraylinxAuthClient with security updates:
| Version | Supported |
| ------- | ------------------ |
| 1.0.x | :white_check_mark: |
| < 1.0 | :x: |
## Security Features
TraylinxAuthClient implements several security measures to protect your authentication credentials and communications:
### Input Validation
- **Comprehensive Parameter Validation**: All configuration parameters are validated using Joi to prevent injection attacks
- **URL Sanitization**: API URLs are validated and sanitized to prevent malicious redirects
- **UUID Format Validation**: Agent User IDs must be valid UUIDs to prevent format-based attacks
### Credential Protection
- **No Credential Logging**: Tokens, secrets, and passwords are never logged or exposed in error messages
- **Secure Memory Handling**: Sensitive data is handled securely in memory and cleaned up appropriately
- **Error Message Sanitization**: Error messages are sanitized to prevent accidental credential exposure
### Network Security
- **HTTPS Enforcement**: All communications use HTTPS with proper certificate validation
- **Timeout Protection**: Configurable timeouts prevent hanging connections and resource exhaustion
- **Rate Limit Handling**: Built-in rate limiting protection with exponential backoff
### Token Security
- **Automatic Token Refresh**: Tokens are automatically refreshed before expiration
- **Async-Safe Token Management**: Token access is protected for concurrent async operations
- **Secure Token Storage**: Tokens are stored securely in memory with appropriate cleanup
## Reporting a Vulnerability
We take security vulnerabilities seriously. If you discover a security vulnerability in TraylinxAuthClient, please report it responsibly.
### How to Report
**DO NOT** create a public GitHub issue for security vulnerabilities.
Instead, please report security vulnerabilities through one of these channels:
1. **Email**: Send details to `security@traylinx.com`
2. **GitHub Security Advisory**: Use GitHub's private vulnerability reporting feature
3. **Direct Contact**: Contact the maintainers directly through secure channels
### What to Include
When reporting a vulnerability, please include:
- **Description**: Clear description of the vulnerability
- **Impact**: Potential impact and attack scenarios
- **Reproduction**: Step-by-step instructions to reproduce the issue
- **Environment**: Node.js version, library version, and operating system
- **Proof of Concept**: Code or commands that demonstrate the vulnerability (if applicable)
- **Suggested Fix**: If you have ideas for fixing the issue
### Example Report Template
```
Subject: [SECURITY] Vulnerability in TraylinxAuthClient v1.0.x
Description:
[Clear description of the vulnerability]
Impact:
[What could an attacker do with this vulnerability?]
Steps to Reproduce:
1. [First step]
2. [Second step]
3. [Additional steps...]
Environment:
- TraylinxAuthClient version: 1.0.x
- Node.js version: v18.x.x
- Operating System: [OS and version]
Proof of Concept:
[Code or commands that demonstrate the issue]
Suggested Fix:
[Your ideas for fixing the vulnerability]
```
## Response Process
### Timeline
We aim to respond to security reports according to the following timeline:
- **Initial Response**: Within 24 hours of receiving the report
- **Vulnerability Assessment**: Within 72 hours of initial response
- **Fix Development**: Depends on complexity, typically 1-2 weeks
- **Security Release**: Within 1 week of fix completion
- **Public Disclosure**: 30 days after fix release (coordinated disclosure)
### Our Commitment
When you report a vulnerability, we commit to:
1. **Acknowledge Receipt**: Confirm we received your report within 24 hours
2. **Regular Updates**: Provide status updates at least weekly during investigation
3. **Credit**: Acknowledge your contribution in the security advisory (if desired)
4. **Coordinated Disclosure**: Work with you on appropriate disclosure timing
5. **Fix Priority**: Treat security issues as high priority
### Severity Classification
We classify vulnerabilities using the following severity levels:
#### Critical (CVSS 9.0-10.0)
- Remote code execution
- Authentication bypass
- Credential theft
- **Response Time**: Immediate (within hours)
#### High (CVSS 7.0-8.9)
- Privilege escalation
- Information disclosure of sensitive data
- Denial of service attacks
- **Response Time**: Within 24 hours
#### Medium (CVSS 4.0-6.9)
- Limited information disclosure
- Input validation issues
- Configuration vulnerabilities
- **Response Time**: Within 72 hours
#### Low (CVSS 0.1-3.9)
- Minor information leaks
- Non-exploitable issues
- **Response Time**: Within 1 week
## Security Best Practices
### For Users
When using TraylinxAuthClient, follow these security best practices:
#### Credential Management
```javascript
// ✅ Good: Use environment variables
const { TraylinxAuthClient } = require('traylinx-auth-client');
const client = new TraylinxAuthClient({
clientId: process.env.TRAYLINX_CLIENT_ID,
clientSecret: process.env.TRAYLINX_CLIENT_SECRET,
apiBaseUrl: process.env.TRAYLINX_API_BASE_URL,
agentUserId: process.env.TRAYLINX_AGENT_USER_ID
});
// ❌ Bad: Hard-coded credentials
const client = new TraylinxAuthClient({
clientId: 'hardcoded_id',
clientSecret: 'hardcoded_secret', // Never do this!
// ...
});
```
#### Secure Configuration
```javascript
// ✅ Good: Secure configuration
const client = new TraylinxAuthClient({
// ... credentials from environment
timeout: 30000, // Reasonable timeout (30 seconds)
maxRetries: 3, // Limited retries
logLevel: 'INFO' // Don't use DEBUG in production
});
// ❌ Bad: Insecure configuration
const client = new TraylinxAuthClient({
// ... credentials
timeout: 300000, // Too long (5 minutes), resource exhaustion risk
maxRetries: 100, // Too many, potential DoS
logLevel: 'DEBUG' // May expose sensitive data in production
});
```
#### Error Handling
```javascript
// ✅ Good: Secure error handling
const { TraylinxAuthError } = require('traylinx-auth-client');
try {
const result = await client.authenticate();
} catch (error) {
if (error instanceof TraylinxAuthError) {
console.error(`Authentication failed: ${error.code}`);
// Don't log the full error (may contain sensitive data)
}
}
// ❌ Bad: Insecure error handling
try {
const result = await client.authenticate();
} catch (error) {
console.error(`Error: ${error.message}`); // May expose credentials
console.log('Full error:', error); // Never log full errors
}
```
#### Express Middleware Security
```javascript
// ✅ Good: Secure middleware usage
const { authMiddleware } = require('traylinx-auth-client');
app.use('/api', authMiddleware({
clientId: process.env.TRAYLINX_CLIENT_ID,
clientSecret: process.env.TRAYLINX_CLIENT_SECRET,
apiBaseUrl: process.env.TRAYLINX_API_BASE_URL,
agentUserId: process.env.TRAYLINX_AGENT_USER_ID,
timeout: 30000,
logLevel: 'INFO'
}));
// ❌ Bad: Insecure middleware usage
app.use('/api', authMiddleware({
clientId: 'hardcoded_id', // Never hardcode credentials
clientSecret: 'hardcoded_secret',
// ... other hardcoded values
logLevel: 'DEBUG' // Don't use DEBUG in production
}));
```
### For Developers
#### Secure Development
- Always validate input parameters using Joi schemas
- Never log sensitive data (tokens, secrets, passwords)
- Use secure defaults for all configuration options
- Implement proper error handling without information leakage
- Follow the principle of least privilege
#### Async Security
```javascript
// ✅ Good: Secure async handling
async function handleRequest(req, res) {
try {
const result = await client.authenticate();
// Process result securely
res.json({ success: true });
} catch (error) {
// Log error securely (no sensitive data)
console.error('Auth failed:', error.code);
res.status(401).json({ error: 'Authentication failed' });
}
}
// ❌ Bad: Insecure async handling
async function handleRequest(req, res) {
const result = await client.authenticate(); // No error handling
res.json(result); // May expose sensitive data
}
```
#### Testing Security
- Include security test cases in your test suite
- Test with invalid and malicious inputs
- Verify that sensitive data is not logged or exposed
- Test timeout and rate limiting behavior
- Use static analysis tools (ESLint security plugins)
## Security Updates
### Notification
Security updates are announced through:
- GitHub Security Advisories
- Release notes in CHANGELOG.md
- npm release notifications
- Email notifications to registered users (if applicable)
### Applying Updates
Always update to the latest version promptly when security updates are released:
```bash
# Update to latest version
npm update traylinx-auth-client
# Or with Yarn
yarn upgrade traylinx-auth-client
# Check for security vulnerabilities
npm audit
npm audit fix
```
### Package Security
Regularly audit your dependencies:
```bash
# Check for known vulnerabilities
npm audit
# Fix automatically fixable vulnerabilities
npm audit fix
# Check for outdated packages
npm outdated
```
## Vulnerability Disclosure Policy
### Coordinated Disclosure
We follow responsible disclosure practices:
1. **Private Reporting**: Vulnerabilities are reported privately first
2. **Investigation Period**: We investigate and develop fixes privately
3. **Coordinated Release**: Security fixes are released with advance notice
4. **Public Disclosure**: Details are disclosed after fixes are available
### Hall of Fame
We maintain a security hall of fame to recognize researchers who help improve our security:
- [Researcher Name] - [Vulnerability Type] - [Date]
- [Add your name by reporting a valid security issue!]
## Node.js Security Considerations
### Version Support
- Use supported Node.js versions (14+)
- Keep Node.js updated to latest LTS versions
- Monitor Node.js security advisories
### Environment Variables
```javascript
// ✅ Good: Secure environment variable usage
const config = {
clientId: process.env.TRAYLINX_CLIENT_ID,
clientSecret: process.env.TRAYLINX_CLIENT_SECRET,
// Validate environment variables exist
};
if (!config.clientId || !config.clientSecret) {
throw new Error('Missing required environment variables');
}
// ❌ Bad: No validation
const config = {
clientId: process.env.TRAYLINX_CLIENT_ID, // May be undefined
clientSecret: process.env.TRAYLINX_CLIENT_SECRET,
};
```
### Memory Management
```javascript
// ✅ Good: Proper cleanup
class SecureClient {
constructor(config) {
this.client = new TraylinxAuthClient(config);
}
async cleanup() {
// Clear sensitive data
if (this.client) {
await this.client.cleanup();
this.client = null;
}
}
}
// ❌ Bad: No cleanup
const client = new TraylinxAuthClient(config);
// Client and tokens remain in memory indefinitely
```
## Contact Information
### Security Team
- **Email**: security@traylinx.com
- **PGP Key**: [Link to public key if available]
- **Response Hours**: Monday-Friday, 9 AM - 5 PM UTC
### Maintainers
- **Primary**: [@maintainer1](https://github.com/maintainer1)
- **Secondary**: [@maintainer2](https://github.com/maintainer2)
## Additional Resources
- [Node.js Security Best Practices](https://nodejs.org/en/docs/guides/security/)
- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
- [npm Security Guidelines](https://docs.npmjs.com/security)
- [GitHub Security Best Practices](https://docs.github.com/en/code-security)
- [CVE Database](https://cve.mitre.org/)
---
Thank you for helping keep TraylinxAuthClient secure!