1 of 52

Secure AI/ML-Driven Software Development (LFEL1012)

David A. Wheeler

Copyright © 2024 The Linux Foundation®. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks.

2 of 52

Outline

  1. Introduction
  2. Context
  3. Key AI concepts for secure development
  4. Security risks of using AI assistants�
  5. Best practices for secure assistant use
  6. Writing more secure code with AI
  7. Reviewing changes in a world with AI�
  8. Wrap-up

3 of 52

Context

4 of 52

Overall context

  • Widely using AI for sw development (incl. generating code) is relatively new
  • We’ll assume security matters in your situation
  • “AI coding assistants are no substitute for experienced developers. An unrestrained use of [assistants] can have severe security implications.”
  • AI requires upskilling of developers
  • Change is inevitable

Sources: [Linux Foundation2025], [BSI2024]

5 of 52

Not covered

  • Securely embedding AI in software being produced
    • Many techniques have been proposed yet don’t work (“99% is a failing grade”) [Willison2023]
    • See [Carlini2019] & CaMeL architecture [Debenedetti2025] & [OWASPAgentic2025]
  • Law, regulations, & ethics relating to AI

Important but out-of-scope

6 of 52

Key AI concepts for secure development

7 of 52

AI, ML, Neural Networks, and LLMs

Machine Learning (ML)

Large Language Model (LLM) Approaches

Neural Network

Artificial Intelligence (AI)

8 of 52

Other basic terms & concepts

  • (Code) assistant
  • Model openness
    • OSI “Open Source AI Definition”, LF AI & Data’s “Model Openness Framework”
  • Generative AI & prompts
  • Agent
  • Tool
  • Model Context Protocol (MCP)
  • Our focus: applying assistants to develop software

9 of 52

Fundamental weaknesses from LLM-like technology

AI

system

Inputs

Outputs

Goal: Use productively, in spite of limitations

LLM (or similar)

Gullible &

context window

Errors & hallucinations

Training issues

10 of 52

Beware of the AI “Lethal Trifecta”

“Cartoon Robot” by Sirrob01, public domain.

Lethal Trifecta per [Willison2025-06-16]

  1. Exposure to untrusted content

2. Access to your private data

3. Ability to externally communicate

11 of 52

Security risks of using AI assistants

12 of 52

Real-world use of assistants

  • Good at “greenfield”
  • Better at “popular” languages
  • Generates lots of code, more needs reworking [Denisov-Blanch2025]
  • Output quality depends on input quality: prompt engineering
  • Consider assistant as a “junior coding partner”
    • Needs guidance & oversight
    • Need tests & other verification

[Denisov-Blanch2025], [Google], [Warren2025]

13 of 52

AI can improve software developer productivity

  • Can improve productivity in “brownfield” in popular languages if properly used
  • “Automation is the fastest way to make mistakes at speed, and AI magnifies that.”

[Denisov-Blanch2025], [Google], [Warren2025]

14 of 52

Two main kinds of security risks using AI assistants

1. Dev Environment

Security failures

from assistant

2. Results

AI generated insecure results

15 of 52

1. Dev environment: Security failures from assistant

  • AI assistant may lead to security failures
    • Exfiltration, tampering, attacks, bills
  • Attackers may trick AI systems
    • AI assistants are gullible
    • Commands can come from anything it reads
    • Malicious commands can be simple
  • Beware of the AI “lethal trifecta” [Willison2025-06-16]
    • Exposure to untrusted content; Access to your private data; & ability to externally communicate
  • Example: Amazon Q Developer extension

16 of 52

2. Results: AI generated insecure results

  • Generated code often has vulnerabilities, especially if no countermeasure taken
  • [Fu2023]: 35.8% contain vulnerabilities, among 42 CWEs
  • [Tihanyi2024]: 62.07% of generated C vulnerable
  • [Perry2022]: less secure, users thought it was more secure
  • [Basic2025] is a survey of LLMs & developing secure software
    • Can generate any kind of vulnerability
    • Can sometimes fix
    • Vulnerable to poisoning attacks
  • Don’t be too trusting

17 of 52

Results: Slopsquatting is a new concern

  • ML systems hallucinate data, including possible packages to reuse
  • Attackers exploit via “slopsquatting
    • ML systems learn patterns, and sometimes hallucinate data
    • Attacker registers malicious software package that an assistant may hallucinate
    • Similar to typosquatting, but exploits AI use
    • [Spracklen2025] found package name hallucination rate of 19.7% across models

18 of 52

What about “vibe coding”?

  • Vibe coding = accepting AI-generated code w/out review or edit
    • Some advocate vibe coding for important resources
    • Pros: Enables non-technical development, learning, faster prototype development
    • Cons: Security/privacy failures, production failures, financial losses
    • As always, there are trade-offs!
  • Vibe coding is fine where there can’t be a serious impact
  • If security matters, don’t vibe code it

Source: [Karpathy2025], [Willison2025-03-19],

Images by ChatGPT & Microsoft Designer

19 of 52

Don’t be a vibe coding victim

  • SaaStr [Sharwood2025]
    • Jason Lemkin: “Day 7 of vibe coding… addictive…”
    • Fake data, fake reports, unit test lies
    • Eventually deleted production database
    • AI tool ignored “don’t do X” directives
  • 45% of AI-generated code contains vulnerabilities [Veracode2025]

Use AI wisely

20 of 52

As always: Manage your risks!

Risk Assessment

Source: ISO 31000:2018

Identification

Analysis

Evaluation

Avoidance

Reduction

Transfer

Acceptance

Risk Treatment

21 of 52

Best practices for secure assistant use

22 of 52

Limit privilege of assistant

  • General security principle “least privilege” still applies
  • Sandbox! VM/container/external system to limit damage
  • Retain control
    • At least, denylist of dangerous commands
    • Consider user confirmation before executing commands unless pre-approved
      • Add to acceptlist. Alterative: strengthen the rest
    • Have control point(s)
    • Have an “off” switch
  • Minimize what assistant can read/write in dev environment
    • Only subdirectories not home directory
  • Disable learning from sensitive data
  • Limit data loss
  • Consider lethal trifecta (next)

Private

Exposure

Externally

Communicate

23 of 52

Cautiously use external data

  • Use caution when giving assistant info from external sources
    • Might include malicious instructions or bad/irrelevant information
  • Common solutions:
    • Prefer authoritative credible sources unlikely to attack
    • Extract only relevant pieces & convert to simple text format
      • Possibly eval/summarize with different restricted AI
    • Occasionally reset to safe state, esp. If its behavior changes
  • Could apply additional countermeasures

Private

Exposure

Externally

Communicate

24 of 52

Limit access to your private data

  • Maximally keep private data out of development systems
    • Keys, production database, PII, unrelated proprietary software, etc.
    • Keep sensitive data encrypted
    • Code should never embed secrets - secret scanners
  • Limit what assistant can access on development system
  • No important unencrypted secrets on system
    • Common MCP blunder
    • Use password manager
  • Rotate secrets

Private

Exposure

Externally

Communicate

25 of 52

Limit ability to externally communicate

  • Strongly limit assistant’s ability to externally communicate
    • Default deny.
    • Access requires approval (including pre-approval), maximally restricted
  • If assistant given API tokens, give separate identity & limit privileges

Private

Exposure

Externally

Communicate

26 of 52

Consider any use of external systems to run assistants

  • Information to/from any external service has risks
    • What might be sent out? (Proprietary, PII, etc.)
    • What might be sent back?
    • Long-term dependency/lock-in?
    • Unbounded bill?
  • Some possible solutions:
    • Evaluate/select trustworthy external services
    • Don’t send sensitive data to external system (e.g., in prompt)
      • Filter prompts, data sources, data contents; education
    • Enable a “privacy mode”
    • Bound costs
    • Local/self-hosting/special systems

27 of 52

Logging

  • Enable logging/history
  • Consider automatic & tamperproof collecting/recording
  • Don’t depend on real-time monitoring or audit as primary mechanism

For more see [ISO/IEC 42001:2023] section B.6.2.8; [NIST AI 600-1] GV-1.2-001, GV-1.5-003, MS-2.8-003

28 of 52

Be cautious about extensions & external configurations

  • Many ways to extend assistants - add tools, data sources, agents, …
    • MCP - tools, data sources, templates
  • Extensions & external configs can improve capabilities
  • Extensions can enable attacks
  • Evaluate before adding each extension
    • Who? What does it do? Have/do anything suspicious?
    • Review its description
    • Review its code
    • Use trustworthy sources
    • Don’t give privileges or API keys unless trustworthy
    • LLM-based evaluation weak

29 of 52

Creating MCP servers

  • Limit access from the network
    • Prefer STDIO (no network). If must use SSE, try 127.0.0.1 (localhost)
    • SSE beyond localhost? Authenticate/authorize, constant-time check
      • Recommends OAUTH; see guidance RFC 9700
  • Implement clear access controls
  • Validate & sanitize all external input
    • Esp. if used in prompt construction, file paths, network requests, shell/command execution
  • Restrict filesystem access
  • Don’t leak internal data
  • Validate data source
  • Consider privacy & document security implications

Sources: [Naamnih2025], [MCP]

30 of 52

Counter well-known attacks on MCP servers

  • Well-known attacks for incorrect MCP servers:
    • Confused deputy, token passthrough, & session hijacking
  • MCP specification “security best practices” explains attacks & identifies required countermeasures [MCP-Security]
    • Read & implement!

Sources: [MCP-BP]

31 of 52

Writing more secure code with AI

32 of 52

How to improve security of code when using assistants

4. Generate tests

5. Verify with humans, tests, and other programs

2. Expressly instruct assistant to generate secure software�3. Trust less/engage more

  1. Apply basics of developing secure software

Basics

Code

Verify

33 of 52

1. Apply basics of developing secure software

  • Learn how to develop secure software yourself
  • Identify requirements & threats
    • of produced software & of development process
  • Secure your infrastructure
  • Design & implement software for security
  • Rigorously apply commit/source code management
  • Use CI/CD to maximally detect problems early
  • Improve process through feedback

34 of 52

2. Expressly instruct assistant to generate secure code

  • Training data has lots of insecure code or secure in different context
  • See OpenSSF’s “Security-Focused Guide for AI Code Assistant Instructions
  • Don’t just say “write secure code” or “You are a security expert”
    • Give specifics, but only relevant specifics
  • Provide meaningful context to assistant
    • Key facts about code, frameworks, language
    • Where trust boundaries are; what’s untrusted
    • Any unusual threats or constraints
  • Use its built-in security evaluation mechanism, if any
  • Break into smaller problems

35 of 52

3. Trust less/engage more

  • Assistants - not replacements [Sonar]
  • KEY: “Find vulnerabilities and other defects in your proposal”/ (if valid) “Fix them.”
  • Review proposed code yourself
  • Engage with the assistant
    • “Analyze [W]. Does it have vulnerability [X] considering [facts]? Justify why or why not.”
    • Provide specific relevant details, don’t assert uncertainties
    • Simple, obviously correct, reuse existing
  • Scrutinize new dependencies. “Is this a hallucination?” [Spracklen2025]
  • Beware: produce answers that look good, not necessarily correct
  • More in section “Reviewing changes in a world with AI”

36 of 52

4. Generate tests: Overall

  • Testing helps prevent defects in production
  • Create tests for new functionality
  • Create automated tests
  • Beware missing tests
    • Have many “negative tests”
    • Check boundary/unusual conditions
  • Beware wrong/unreliable tests

37 of 52

4. Generate tests: AI generated tests

  • AI can help many test-related tasks [testrigor]
  • Our focus: Assistants to create/modify tests
  • Consider creating test before code
  • Carefully review generated tests
    • Incorrect tests mislead assistants
    • Useless tests slow development & testing
  • Depend on data quality [powerdrill]
    • Comments, naming, docs
  • Ask for improvements

38 of 52

5. Verify with humans, tests, and other programs

  • Humans and assistants make mistakes
  • Have verification process to detect problems early
    • Use multiple approaches

39 of 52

Reviewing changes in a world with AI

40 of 52

Basics of reviewing proposed changes

  • Humans responsible for work of assistants, must review if security matters
  • Use many automated approaches
    • Tests: automated, good coverage, negative tests
    • Static analysis: linters/style checkers, SAST, secret scanners, …
    • Dynamic analysis (other than tests): Fuzz testing, web application scanners, …
  • Where practical, independent human review
  • Reviewing another’s work? Require clear description

41 of 52

Human review: Some things to consider

  • LLMs create all different kinds of vulnerabilities [Basic2025]
    • OWASP Top 10, CWE Top 25
  • Most likely underlying causes from LLMs [Dilgren2025]:
    • Missing conditional check
    • Incorrect memory allocation (when using memory-unsafe languages)
    • Incorrect conditional check
  • Maximize clarity and accuracy (for humans and AI)
    • Good names, inline comments, merge/pull request descriptions
  • Emphasize simple/clear code & reusing existing mechanisms

42 of 52

Beware of adding new dependencies

  • Modern sw development depends on reuse (esp. OSS)
  • Reuse software wisely. Dependencies can:
    • Be a poor fit
    • Add effort to keep updated
    • Be malicious/become subverted (supply chain attack)
  • As noted, special weakness of AI-generated code is slopsquatting
  • Solution: review any proposed new dependency
    • Recent date? Big?
    • Many “big” projects use it?
    • See OpenSSF “Concise Guide for Evaluating Open Source Software
    • If unusual, check further

43 of 52

Human review: Reviewing others’ work with assistants

  • Assistants can be used to review proposed changes - even from others
    • See previous “Trust less/engage more”
  • Vulnerable to any malicious instructions embedded in the change
  • Can also evaluate whole program for vulnerabilities
  • False+ and false-
  • Don’t simply trust AI

44 of 52

Countering low-quality external proposals

  • Many projects (incl. most OSS) accept external reports and change proposals
    • AI can create low-quality material (“AI slop”)
    • Denial-of-service (DoS) attack on maintainer time
  • Counter low-quality inputs
    • Clarify: slop isn’t acceptable
    • Require explanation of problem & how proposal solves it
    • Require it pass all existing tests & CI programs
    • Require adding tests for any new functionality
  • Check submitter reputation
  • Then, more detailed look

45 of 52

Wrap-up

46 of 52

Pragmatic Coders’ Recommendations

  • Keep Your Code and Data Safe While Using AI [Assistants]
    • Developer’s Responsibility
    • Manage Sensitive Information
    • Beware of External AI Configurations
    • No Shortcuts in Testing and Validation
  • Control AI’s Behavior When Coding
    • Guide the AI with Clear Prompts
    • Double-Check Dependencies
    • Require User Confirmation
    • Protect Sensitive Data in Prompts
  • Minimize Risk in AI-Assisted Coding
    • Block Destructive Commands
    • Limit AI’s Access
    • Control Integration Points
    • Set Resource Limits
    • Disable Learning from Sensitive Code

Source: Pragmatic Coders, Secure AI-Assisted Coding: A Definitive Guide, https://www.pragmaticcoders.com/blog/secure-aiassisted-coding-guide

47 of 52

Conclusions

  • It is possible to use AI to develop software while maintaining security
  • Human developers are responsible for the software they develop
    • Even with AI assistants
  • Learn how to develop secure software yourself
  • Keep learning! Technology changing, new uses
  • When using assistants, take steps to:
    • securely use assistants
    • develop secure results

48 of 52

Thank You

49 of 52

References

50 of 52

References

51 of 52

References

52 of 52

Legal Notice

Copyright © Open Source Security Foundation®, The Linux Foundation®, & their contributors. The Linux Foundation has registered trademarks and uses trademarks. All other trademarks are those of their respective owners.

Per the OpenSSF Charter, this presentation is released under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at <https://creativecommons.org/licenses/by/4.0/>. You are free to:

  • Share — copy and redistribute the material in any medium or format for any purpose, even commercially.
  • Adapt — remix, transform, and build upon the material for any purpose, even commercially.

The licensor cannot revoke these freedoms as long as you follow the license terms:

  • Attribution — You must give appropriate credit , provide a link to the license, and indicate if changes were made . You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.