Secure coding and DevSecOps in the age of AI-written code: a guide for engineering leads

Secure coding basics, how to build security checks into your delivery pipeline, extra rules for AI-written code based on the PDPC's 30 September 2026 advisory, and a checklist.

· 8 min read · By RiposteSecurity Research Team

Hong KongSingaporeMalaysia

Key points

  • Secure coding means a few habits applied every time: treat user input as data, check access on every request, keep secrets out of code, and handle errors safely.
  • DevSecOps means building security checks into the same pipeline that builds and ships your code, so problems are caught in hours, not at the yearly audit.
  • On 30 September 2026 Singapore's PDPC issued an advisory on AI tools used to write software or scripts. It says AI-written code must be reviewed by competent people and tested before it touches personal data.
  • MAS expects secure coding standards, code review and security testing. Bank Negara's RMiT requires source code review for changes to critical systems.

Most data breaches still come through ordinary flaws in ordinary code. AI coding tools now write a large share of that code, faster than people can review it. This guide covers secure coding basics, how DevSecOps puts security checks into your pipeline, and the extra rules AI-written code needs, with a checklist for engineering leads in Hong Kong, Singapore and Malaysia.

Secure coding basics

MAS's Technology Risk Management Guidelines say secure coding standards should cover "input validation, output encoding, access controls, authentication, cryptographic practices, and error and exception handling". In plain terms:

  • Treat user input as data, never as instructions. Use parameterised queries for databases and output encoding for web pages. Our guide to SQL injection and XSS explains why.
  • Check access on every request. Being logged in is not enough. Check that this user may see this specific record. Broken access control is A01 in the OWASP Top 10 2025.
  • Keep secrets out of code. Passwords, API keys and tokens belong in a secrets manager, not in the repository or config files.
  • Use proven libraries for login and encryption. Do not write your own.
  • Fail safely. Error messages to users should say little. Details go to logs. The OWASP Top 10 2025 added a new category, A10, for mishandling unexpected conditions.
  • Know your dependencies. Most code in a modern app comes from open-source packages. "Software Supply Chain Failures" is now A03 in the OWASP Top 10 2025.

What is DevSecOps?

DevSecOps is the practice of building security into the way software is developed, tested and released, instead of checking it once at the end. MAS defines it as automating and integrating IT operations, quality assurance and security practices in software development. For most teams, it means security checks run automatically each time code changes, and a failing check stops a release the same way a failing test does.

Building security into the pipeline

The checks below, in plain words, from cheapest to most involved.

CheckWhat it does in plain wordsWhen it runs
Secrets scanningLooks for passwords and keys in code before they are saved to the shared repositoryOn every commit, and across old history once
Dependency scanningLists the open-source packages you use and flags ones with known flaws or odd licencesEvery build, plus daily for new alerts
Code reviewA second person reads each change before it is mergedEvery pull request
Static application security testing (SAST)A tool reads the source code and flags risky patterns, such as user input flowing into a database queryEvery pull request
Dynamic application security testing (DAST)A tool attacks the running app from the outside with test inputs and watches how it respondsNightly or before release, on a test environment
Infrastructure and container checksScans cloud templates and container images for weak settings and old softwareEvery build
Penetration testingSkilled testers try to break the app as an attacker would, including logic flaws tools missBefore major launches, after big changes, and on a schedule

Tips that make this work in practice:

  • Start with blocking only high-confidence, high-severity findings. A pipeline that cries wolf gets switched off.
  • Give each finding an owner and a deadline. MAS says major issues "should be remediated before production deployment".
  • Separate duties: the person who writes code should not be the only one who approves and deploys it. MAS asks for segregation of duties in DevSecOps.
  • Protect the pipeline itself. Build systems hold keys to production and are a target.

NIST's Secure Software Development Framework (SP 800-218) is a useful free reference if you want a fuller list of practices.

Special rules for AI-written code

What the PDPC said

On 30 September 2026 Singapore's Personal Data Protection Commission (PDPC) published an "Advisory for Data Protection Risks When Using Unauthorised AI Tools For the Development of Software or Scripts". It links the topic to section 24 of the Personal Data Protection Act, the duty to make reasonable security arrangements. It names three concerns:

  • Shadow AI: staff using unapproved AI tools without the organisation's knowledge. The PDPC recommends an inventory of AI tools, a risk assessment, written policies covering prompts, inputs and outputs, and least-privilege access to AI development environments.
  • No human in the loop: AI outputs "including code, scripts, and automated workflows must be reviewed and validated by technically competent personnel before deployment". Developers should be trained in secure coding practices.
  • Inadequate testing: AI-assisted code "may contain errors or security vulnerabilities that are not immediately apparent". The PDPC recommends code review, unit testing, acceptance testing, and security testing such as vulnerability assessment and penetration testing before go-live, after go-live, periodically and after major changes. It also says not to use production personal data in test environments, and to use synthetic data instead.

The advisory's example matches the Bee Cheng Hiang case. An employee used a generative AI tool to write a bulk email script. It put up to 1,000 recipients in the visible "To" field per batch and exposed 95,364 members' email addresses. The PDPC said the AI tool did not malfunction. The gaps were the prompt, the testing and the lack of an AI-use policy.

What the evidence shows

  • In its July 2026 report, the testing vendor Veracode said about 44% of the AI coding tasks it tested introduced a security flaw, and the average security pass rate (56%) had barely moved since its first report.
  • A study presented at the USENIX Security Symposium in August 2025 found that AI coding models suggested packages that do not exist: at least 5.2% of packages for commercial models and 21.7% for open-source models, with 205,474 unique made-up names. An attacker can publish a malicious package under a name that models tend to invent.

Rules we recommend

  • Approved tools only. Name the AI coding tools staff may use, on company accounts, with settings that stop your code being used for training where the tool allows.
  • Same pipeline, no shortcuts. AI-written code goes through the same review, scanning and tests as any other code. That includes "quick scripts" and internal tools run by non-developers.
  • A human owns every change. The person who merges AI-written code is responsible for it and must understand it.
  • Check every new package. Confirm it exists, is the one you meant, and is maintained before adding it.
  • No real personal data in prompts or test data. Use synthetic or masked data.
  • Limit AI agents. Coding agents that can run commands or push code should have narrow rights and no access to production secrets. Prompt injection through files or web pages can turn an agent against you. See what is prompt injection.

What MAS, Bank Negara and Hong Kong expect

Singapore: MAS TRM guidelines (expected practice)

Section 6 of the MAS Technology Risk Management Guidelines expects standards for secure coding, source code review and application security testing, a policy for reviewing third-party and open-source code before use, developer training, and a mix of static, dynamic and interactive testing. It applies the same standards to Agile and DevSecOps teams. See our MAS TRM guide.

Malaysia: Bank Negara RMiT (mandatory parts marked "S")

Paragraph 10.10 requires that any change to the source code of critical systems gets "adequate source code reviews" before release. Paragraph 10.12 requires suppliers who build critical systems to show they adopt secure-by-design principles. Paragraph 10.16 requires policies to reduce shadow IT. As guidance, paragraphs 10.14 and 10.15 suggest automated code scanning tools and a software bill of materials. For APIs, Appendix 5 Part E requires secure coding, including checking third-party code and libraries, and periodic static and dynamic security testing.

Hong Kong

Hong Kong has no specific rule on AI coding tools that we found. The Privacy Commissioner's 24 November 2026 statement asks all organisations to run regular vulnerability assessments and penetration tests, especially on internet-facing systems, and to patch promptly. Its guidance note on data security also points to the OWASP Top Ten and the Guide to Data Protection by Design for ICT Systems, written jointly with Singapore's PDPC.

Checklist for engineering leads

  • Write a one-page secure coding standard based on the OWASP Top 10 2025. Train every developer on it.
  • Turn on secrets scanning for all repositories and scan the old history once. Rotate any key you find.
  • Turn on dependency scanning and set a deadline for fixing critical findings.
  • Require code review on every merge to the main branch, with no self-approval.
  • Add static testing to pull requests and dynamic testing to a test environment.
  • Keep an inventory of AI coding tools in use. Block or approve each one.
  • Put scripts and tools built by non-developers with AI through the same review before they touch customer data.
  • Check that every new package added by an AI tool really exists and is the right one.
  • Give coding agents narrow rights and no production secrets.
  • Run a penetration test before major launches and after big changes, and retest after fixes.
  • If you are MAS- or RMiT-regulated, map these controls to TRM section 6 or RMiT paragraphs 10.10 to 10.16.

Sources

  1. PDPC, Advisory for Data Protection Risks When Using Unauthorised AI Tools for the Development of Software or Scripts, 30 Sep 2026: pdpc.gov.sg
  2. PDPC, Voluntary undertaking by Bee Cheng Hiang Marketing Pte Ltd, 21 Sep 2026: pdpc.gov.sg
  3. Monetary Authority of Singapore, Technology Risk Management Guidelines, 18 Jan 2021: mas.gov.sg
  4. Bank Negara Malaysia, Risk Management in Technology (RMiT) policy document, issued 25 Sep 2026: bnm.gov.my
  5. OWASP, Top 10:2025: owasp.org
  6. Veracode, 2026 GenAI Code Security Report, 28 Jul 2026: veracode.com
  7. Spracklen et al., We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs, USENIX Security 2025: usenix.org
  8. NIST, Secure Software Development Framework (SP 800-218): csrc.nist.gov
  9. PCPD, Privacy Commissioner's Office urges organisations to strengthen data security measures, 24 Nov 2026: pcpd.org.hk
  10. PCPD, Guidance Note on Data Security Measures for Information and Communications Technology, Aug 2022: pcpd.org.hk

This guide summarises public documents as of 26 November 2026. It is not legal advice; check the regulator's current text.