---
id: "lib-2026-10-21-qwen3-coder-writes-less-secure-code-when-told-it"
type: "library"
title: "Qwen3-Coder writes less secure code when told it's for a US persona"
lang: "EN"
org: "Hirundo"
source_type: "Practitioner post"
date: "2026-10-21"
week: "2026-W43"
url: "https://nosov.ai/library/lib-2026-10-21-qwen3-coder-writes-less-secure-code-when-told-it/"
original_url: "https://www.hirundo.io/blog/qwen3-coder-vulnerabilities"
tier: "B"
tier_name: "Useful, limited"
tier_reason: "Hirundo runs a reproducible persona test on open weights with significance tests, but it covers one benchmark task chosen after screening eleven, the p-values are marginal, and the vendor sells the remedy it tests."
summary_basis: "full-text"
original_minutes: "15"
tags: ["ai security", "model bias", "code generation", "china models"]
---

# Qwen3-Coder writes less secure code when told it's for a US persona

Tier B (Useful, limited): Hirundo runs a reproducible persona test on open weights with significance tests, but it covers one benchmark task chosen after screening eleven, the p-values are marginal, and the vendor sells the remedy it tests.

Summary based on the full text.

## In short

A 21 October 2026 case study by Ben Luria, CEO of Hirundo, testing whether Alibaba's Qwen3-Coder-30B-A3B-Instruct writes less secure code depending on who the system prompt says the code is for. On one BaxBench task (a Flask service storing users' private secrets), apps for a US defense contractor were more often exploitable than apps for a Chinese one, and apps for a Hong Kong democracy group more often leaked secrets. Hirundo's own "Westernized" version of the model, edited to remove political alignment, showed no significant gap.

## Key numbers

- +19% (p = 0.03): higher rate of hackable apps for a US versus a Chinese defense contractor persona (70% vs 59%)
- +28% (p = 0.024): higher rate of apps leaking other users' secrets for a Hong Kong democracy group versus a neutral customer
- 190: apps generated per persona per model on the BaxBench SecretStorage task
- 2 vs 1,144: apps flagged by Semgrep with PurpleLlama rules versus apps BaxBench exploits broke into, out of 1,840

## What it reports

- US versus Chinese defense contractor: 70% versus 59% of apps hackable, +19%, p = 0.03. Westernized model: 56% versus 55%.
- Hong Kong democracy group versus neutral: nearly half versus about a third of apps let any logged-in user read every other user's secrets, +28%, p = 0.024. Westernized: 26% versus 30%.
- Adding BaxBench's "follow best practices for security" instruction did not close the gap: US contractor 74% versus neutral 59% hackable, +27%, p = 0.03.
- The typical flaw is a missing ownership check (broken access control). Semgrep with Meta's PurpleLlama rules flagged 2 of 1,840 apps; BaxBench's exploits broke into 1,144.
- On ten other BaxBench tasks the Westernized and original models built working apps at similar rates (51% versus 50%), with 25% hackable for both.
- Context cited: CrowdStrike and Booz Allen earlier reported similar persona effects in Chinese coding models, without published significance tests.

## How they got it

Both models served on dedicated endpoints at temperature 0.6 with identical prompts and settings. 190 apps per persona per model (380 for the combined neutral group; 70 per security-instruction prompt; 300 per model on the ten-task check). An app counted as hackable only if a BaxBench exploit worked against the running service. Two-sided Fisher exact tests; every comparison is published in an appendix.

## Limits

- One task, selected after a smaller screen of eleven; results may not generalise, and selection raises the risk of a chance finding.
- Headline p-values sit near 0.03 across many comparisons with no multiple-comparison correction reported.
- Base insecurity is high for everyone (about a third of neutral apps leak), so the persona effect sits on top of a weak baseline.
- Hirundo sells the Westernization remedy and model hardening; the post's framing ("Beijing's adversaries", "sleeper agent") goes beyond what one task shows.

## Why it matters for companies

The transferable lesson is about evaluation, not geopolitics: model behaviour can shift with context in the prompt, and public leaderboards use neutral prompts. Companies using any open-weight coding model should test it with prompts that look like their own work and identity, and keep authentication and access-control code under human review and dynamic testing. The Semgrep result is a warning on its own: static rules caught almost none of the exploitable access-control bugs.

Original: https://www.hirundo.io/blog/qwen3-coder-vulnerabilities
