Malta Digital Skills and Jobs Platform (LISP)

Developing Secure Code in the Age of Generative AI

In modern software development, security cannot be an afterthought. With increasing reliance on cloud services, APIs, and generative AI tools, developers must adopt disciplined, secure coding practices to protect applications and data throughout the software development lifecycle (SDLC). Industry-recognised frameworks such as the OWASP Secure Coding Practices and training from the SANS Institute provide foundational guidance for building secure software.

1. Embed Security from Day One
Secure coding starts long before the first line of code is written. Quality requirements should include clear security objectives tied to business risk, compliance, and user data protection. Taking a threat-modelling approach early helps identify likely attack vectors and informs design decisions that reduce vulnerabilities later. Tools such as STRIDE or OWASP’s threat modelling resources can assist here.
Skills development is always critical, and therefore, developers and architects should engage in formal upskilling education covering common web and API risks, such as the OWASP Top 10, which remains a widely used taxonomy of critical application security flaws.

2. Use Secure Coding Standards and Checklists
Adopt a secure coding standard based on the OWASP Secure Coding Practices Quick Reference Guide. This checklist-style document defines concrete coding requirements and best practices that can be integrated into everyday development. It covers areas such as input validation, authentication, access control, error handling, and cryptography.
Some essential practices include:
• Input Sanitisation and Validation: Assume all input is untrusted; enforce strict validation and sanitisation to protect against injection attacks and cross-site scripting (XSS).
• Output Encoding: Encode user data before rendering it in different contexts (HTML, SQL, OS commands) to ensure malicious content isn’t inadvertently executed.
• Parameterised Queries: Avoid concatenated SQL or command strings; use parameterised or prepared statements to prevent injection.
• Access Control: Apply the principle of least privilege when granting permissions and enforce strong authentication and session management.

3. Automate Security Testing
Manual code reviews are indispensable, but automating routine security checks scales quality across teams:
• Static Application Security Testing (SAST) to integrate static analysis tools into your CI/CD pipeline to catch insecure patterns before merge.
• Dynamic Application Security Testing (DAST) to simulate attacks against running services to detect issues that only appear at runtime.
• Software Composition Analysis (SCA) to scan dependencies for known vulnerabilities and problematic licenses.
SANS highlights the importance of hands-on labs and secure SDLC training to sharpen developers’ ability to find and fix vulnerabilities in environments that resemble real work.

4. Integrate Security Reviews into the Development Rhythm
Security reviews should occur at multiple checkpoints:
• Design Reviews to evaluate architectural decisions for security implications.
• Code Reviews to include security criteria in peer review checklists.
• Pull-Request Gates to only merge code after passing automated checks and review sign-offs.
Coupling secure code reviews with continuous integration ensures that potential flaws are caught early, reducing costly fixes later.

5. Handle Error Logging and Secrets Safely
Avoid exposing internal system details through verbose error messages. Log securely for diagnostic purposes, but ensure logs are accessible only to authorised personnel. Protect secrets and keys by using secure vaults and environment variables; never hard-code sensitive information in source repositories.

6. Securely Leverage Generative AI
The use of generative AI in coding tasks offers productivity gains but introduces new risks. OWASP’s 2025 update warns of inappropriate trust in AI-generated code (“vibe coding”). Code automatically written by AI without critical human oversight is a high risk, and developers remain responsible for all committed code.
Best practices when using AI include:
• Understanding and Vetting AI Code to review and manually verify AI-suggested code for security risks.
• Using Guardrails to leverage policy enforcement tools or RAG (Retrieval Augmented Generation) servers to constrain AI output to organisation-approved secure patterns.
• Train Prompts for Security to develop prompt templates that explicitly instruct AI models to adhere to internal secure coding standards.
In 2025, OWASP and SANS collaborated to draft unified AI security controls, addressing domains such as access, data governance, and monitoring. This is a strong indication that securing AI systems is now a shared priority across major security communities.

7. Maintain and Monitor Post-Deployment
Security does not stop once software is deployed. Teams must regularly run vulnerability scans, continuously monitor systems for unusual behaviour, and quickly apply security patches to dependencies. Effective logging and monitoring help detect and respond to incidents early, before they become serious problems
Source: OWASP, SANS