This document describes the security features and measures implemented in the TaskFlow Platform.
The Database Integration feature includes comprehensive protection against SQL injection attacks and other security threats.
- Only SELECT and WITH (CTE) queries are allowed
- Write operations (INSERT, UPDATE, DELETE, DROP, etc.) are completely blocked
- Prevents data modification or deletion
The following SQL keywords are blocked:
DROP,DELETE,TRUNCATE,ALTER,CREATE,INSERT,UPDATEGRANT,REVOKE,EXEC,EXECUTE- SQL Server procedures:
xp_,sp_ - Comment markers:
--,/*,*/ - Script injection:
script,javascript,vbscript,onload,onerror
Word Boundary Validation: Keywords are checked as whole words only, preventing false positives. For example:
- ✅
SELECT created_at FROM tasks- Allowed (column name) - ❌
CREATE TABLE test- Blocked (dangerous keyword)
- Comment-based injection: Detects
--,/*,*/patterns - UNION-based injection: Detects multiple UNION statements or suspicious UNION patterns
- Stacked queries: Detects multiple statements separated by semicolons
- Maximum query length: 10,000 characters
- Prevents extremely long queries that could cause performance issues
All suspicious activity is logged with:
- User ID
- Query content
- Reason for blocking
- Timestamp
Example alert format:
╔══════════════════════════════════════════════════════════════╗
║ 🚨 SECURITY ALERT - SQL INJECTION ATTEMPT ║
╠══════════════════════════════════════════════════════════════╣
║ User ID: admin ║
║ Reason: Query contains prohibited keyword: DROP ║
║ Query: DROP TABLE users; -- ║
║ Timestamp: Fri Jan 30 03:12:05 UTC 2026 ║
╚══════════════════════════════════════════════════════════════╝
Location: backend/task-service/src/main/java/io/celox/taskflow/task/controller/DatabaseController.java
Key Methods:
validateQuery()- Validates query for security threatscontainsSqlInjectionPattern()- Detects SQL injection patternslogSecurityAlert()- Logs security alerts
Query Processing:
- Query is trimmed and validated
- Trailing semicolons are automatically removed (JdbcTemplate requirement)
- Security validation runs before execution
- Only validated queries are executed
Error Handling:
- Root cause extraction from exception chain for clearer error messages
- PostgreSQL error messages are directly shown to users (e.g., "ERROR: column 'name' does not exist")
- SQL syntax errors are not logged as security alerts (only actual security threats trigger alerts)
- Improved error messages help users identify and fix query issues quickly
- Tokens are validated on every request
- Invalid or expired tokens are rejected
- Automatic redirect to login on authentication failure
- 401 Unauthorized: Returned when user is not authenticated
- 403 Forbidden: Returned when user lacks required permissions
- Clear error messages guide users to resolve authentication issues
- Tokens stored in
localStorage(frontend) - Automatic token attachment to API requests via
axiosInstance - Automatic cleanup on authentication errors
- Never bypass security validations - All queries must go through validation
- Monitor security logs - Review alerts regularly
- Keep dependencies updated - Security patches are important
- Use parameterized queries - When adding new database operations
- Use SELECT queries only - Write operations are not permitted
- Avoid suspicious patterns - Even in legitimate queries
- Report security issues - Contact administrators if you encounter problems
| Feature | Status | Description |
|---|---|---|
| SQL Injection Protection | ✅ Active | Multi-layer validation and pattern detection |
| Query Type Restrictions | ✅ Active | Only SELECT and WITH queries allowed |
| Keyword Blocking | ✅ Active | Dangerous keywords blocked with word boundaries |
| Security Alert Logging | ✅ Active | All suspicious activity logged |
| Authentication | ✅ Active | JWT-based authentication required |
| Authorization | ✅ Active | Role-based access control |
| Error Handling | ✅ Active | Clear error messages without exposing internals |
Security alerts are logged to:
- Application logs (standard output)
- System error stream (
System.err) - Can be integrated with log aggregation tools (ELK, Splunk, etc.)
If you discover a security vulnerability, please:
- Do not create a public issue
- Contact: security@celox.io
- Include detailed information about the vulnerability
- Allow time for the issue to be addressed before public disclosure
Last Updated: February 2026
Version: 1.1