Repository navigation
Draft: Roadmap to harden the application using genAI
K. C. Ramakrishna edited this page Nov 19, 2024
·
1 revision
We are a small team with limited resources. While we had senior developers on our team, we did not have dedicated security experts. To achieve world class security, we decided a 2 step approach.
- Leverage genAI wherever we can to harden the code and configurations to improve the security posture
- Engage security professionals AFTER we have done our part.
This dramatically reduced our cost for getting to world-class security. Security is an ongoing process and we will update this documentation as we make more progress.
-
Secure Coding Practices
- Implement input validation and sanitization to prevent common vulnerabilities like cross-site scripting (XSS), SQL injection, and command injection
- Use parameterized queries or prepared statements to mitigate SQL injection risks
- Implement proper error handling and avoid exposing sensitive information in error messages
- Use secure coding practices specific to React/TypeScript, NEST, and Java/Quarkus
- Conduct regular code reviews to identify and fix security vulnerabilities
- Comments
- We used genAI to suggest libraries for input validations and sanitization in our REACT/Typescript.
- We used class-validator in NEST as well as Java/Quarkus inbuilt mechanisms
- We had already upgraded our error handling using genAI (Cody)
- Todo: Create custom prompts in Cody to analyse and upgrade code right at the time of writing the code.
-
Authentication and Authorization
- Implement strong and secure authentication mechanisms (e.g., multi-factor authentication, password policies)
- Use Keycloak or other robust identity and access management solutions
- Implement proper session management and secure session handling
- Enforce strong password policies and consider using password hashing algorithms like bcrypt
- Implement proper authorization checks to ensure users can only access resources they are allowed to
- Comments
- We use KeyCloak for all authentication.
- We enabled SSO with google(and other identity providers like Microsoft, Facebook).
- For the few users who want to create an id with us, we direct them to Keycloak inbuilt mechanisms to enforce high security.
- We secured Keycloak itself by leveraging genAI to implement best practices in hardening and performance.
- Todo: Illustrate the hardened config file.
- We use KeyCloak for all authentication.
-
Secure Communication
- Use HTTPS/SSL for all communication between the client and server
- Implement proper certificate validation and use strong encryption algorithms
- Use secure cookies with the "Secure" and "HttpOnly" flags set
- Implement Content Security Policy (CSP) headers to prevent cross-site scripting and other attacks
- Comments
- We hardened our public facing ngnix
- We used the same approach and leveraged genAI to harden ALL our internal dockers, components and application.
-
Secure Configuration
- Follow the principle of least privilege and configure components with minimal necessary permissions
- Disable or remove unnecessary services, ports, and protocols
- Use secure default configurations for all components (e.g., Elastic, MariaDB, Keycloak, Nginx)
- Keep all components and dependencies up to date with the latest security patches
- Comments
- We used the same approach and leveraged genAI to harden ALL our internal dockers, components and application.
- Todo: Link some examples of the hardened configuration files and the prompts used in the process.
-
Database Security
- Use strong authentication and access controls for the database (MariaDB)
- Implement proper database user roles and permissions
- Encrypt sensitive data at rest and in transit
- Regularly backup and monitor the database for any suspicious activities
- Comments
- Todo: Create the documentation and link it here.
-
Secure Integration with Third-Party Services
- Ensure secure integration with Stripe for payment processing
- Properly validate and sanitize any data received from third-party services
- Use secure APIs and follow the security best practices provided by the third-party services
- Comments
- Todo: Create the documentation and link it here.
-
Containerization and Deployment Security
- Implement secure containerization practices using Docker
- Use minimal and secure base images for containers
- Scan container images for vulnerabilities and ensure they are up to date
- Implement proper network segmentation and isolation between containers
- Use secure deployment practices and ensure proper access controls for deployment environments
- Comments
- Todo: Create the documentation and link it here.
-
Security Testing and Monitoring
- Conduct regular security assessments, including vulnerability scanning and penetration testing
- Implement continuous integration and continuous deployment (CI/CD) pipelines with security checks
- Monitor application logs and system events for suspicious activities
- Implement intrusion detection and prevention systems (IDPS)
- Establish an incident response plan and conduct regular security drills
- Comments
- This will be taken up with external consultants once we finish our internal hardening
-
Security Policies and Awareness
- Develop and maintain a comprehensive security policy for the organization
- Provide regular security training and awareness programs for developers and other team members
- Implement secure development lifecycle (SDLC) practices and integrate security into the development process
- Conduct regular security audits and risk assessments
- Comply with relevant industry standards and regulations (e.g., OWASP, NIST, ISO 27001)
- Comments
- Basic systems are in place.
- Audit with external consultants once we finish our internal hardening
Security is an ongoing process. Expect more updates in this section as we go forward.