| Version | Supported |
|---|---|
| 1.0.x | ✅ |
| < 1.0 | ❌ |
If you discover a security vulnerability in php-ymap, please report it privately:
DO NOT open a public GitHub issue for security vulnerabilities.
- Email: Send details to the maintainers via GitHub (use the "Report a security vulnerability" feature in the Security tab)
- Include:
- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if available)
- Acknowledgment: Within 48 hours
- Initial assessment: Within 1 week
- Fix timeline: Depends on severity and complexity
- Credit: You will be credited in the security advisory (unless you prefer to remain anonymous)
DO:
- Store IMAP credentials in environment variables
- Use secure vaults (AWS Secrets Manager, HashiCorp Vault, etc.)
- Rotate credentials regularly
- Use application-specific passwords when available
DON'T:
- Hardcode credentials in source code
- Commit credentials to version control
- Log credentials in plain text
- Share credentials across multiple applications
php-ymap supports both the socket connector (default) and the optional native IMAP extension connector. In both cases, enforce TLS:
$config = new ConnectionConfig(
'{imap.example.com:993/imap/ssl}INBOX',
getenv('IMAP_USER'),
getenv('IMAP_PASS')
);Flags for secure connections:
/imap/ssl- Use SSL/TLS encryption/imap/ssl/novalidate-cert- Avoid in production (disables certificate verification)
When using php-ymap in web applications:
- Sanitize user inputs before using in IMAP searches
- Validate email addresses before using in filters
- Limit result sets to prevent resource exhaustion
- Implement rate limiting on IMAP operations
When processing attachments:
// Sanitize filenames before saving to disk
$filename = basename($attachment->getFilename());
$filename = preg_replace('/[^a-zA-Z0-9._-]/', '_', $filename);
// Validate file types
$allowedTypes = ['image/jpeg', 'image/png', 'application/pdf'];
if (!in_array($attachment->getContentType(), $allowedTypes)) {
// Reject or handle appropriately
}
// Limit file sizes
if ($attachment->getSize() > 10 * 1024 * 1024) { // 10MB
// Reject large attachments
}Prevent memory exhaustion:
// Limit number of messages fetched
$messages = $service
->inbox()
->limit(100) // Don't fetch unbounded result sets
->fetch();
// Use field selection to reduce memory usage
$messages = $service
->inbox()
->fields(['uid', 'subject', 'from', 'date']) // Omit large bodies
->fetch();-
Connector Choice: Socket mode is the default runtime path. If you enable
ext-imap, keep PHP and extension packages updated. -
Memory Usage: Large attachments can exhaust memory if fully materialized. Prefer metadata-only fetches and streaming for large files.
-
Connection Security: Always use SSL/TLS for IMAP connections when connecting over untrusted networks.
When a security issue is fixed:
- A security advisory will be published on GitHub
- CHANGELOG.md will be updated with security fix details
- A new patch version will be released
- Affected versions will be clearly documented
Subscribe to security advisories:
- Watch the GitHub repository for security alerts
- Check CHANGELOG.md for security-related fixes