Title: Python: taint is lost through list.extend, list.insert and += , but not list.append · Issue #22305 · github/codeql · GitHub
Open Graph Title: Python: taint is lost through list.extend, list.insert and += , but not list.append · Issue #22305 · github/codeql
X Title: Python: taint is lost through list.extend, list.insert and += , but not list.append · Issue #22305 · github/codeql
Description: Summary CodeQL's Python taint tracking propagates through list.append, but not through list.extend, list.insert, or += on a list. A security query therefore reports a flow written one way and stays silent on the same flow written another...
Open Graph Description: Summary CodeQL's Python taint tracking propagates through list.append, but not through list.extend, list.insert, or += on a list. A security query therefore reports a flow written one way and stays...
X Description: Summary CodeQL's Python taint tracking propagates through list.append, but not through list.extend, list.insert, or += on a list. A security query therefore reports a flow written one way and s...
Opengraph URL: https://github.com/github/codeql/issues/22305
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python: taint is lost through list.extend, list.insert and += , but not list.append","articleBody":"### Summary\n\nCodeQL's Python taint tracking propagates through `list.append`, but not through `list.extend`, `list.insert`, or `+=` on a list. A security query therefore reports a flow written one way and stays silent on the same flow written another way, where the two differ only in which list-mutation method is used.\n\nI'm reporting the **asymmetry** rather than the incompleteness: `append` is clearly modelled, so the other three look like a gap in the same model rather than a deliberate boundary.\n\n### Reproducer\n\nEach snippet is the same flow — a request parameter reaching `subprocess.call(..., shell=True)` — differing only in how the value passes through a list.\n\n```python\n# reported\ndef handler():\n user = request.args.get(\"cmd\")\n acc = [user]\n subprocess.call(acc[0], shell=True)\n\n# reported\ndef handler():\n user = request.args.get(\"cmd\")\n acc = []\n acc.append(user)\n subprocess.call(acc[0], shell=True)\n\n# NOT reported\ndef handler():\n user = request.args.get(\"cmd\")\n acc = []\n acc.extend([user])\n subprocess.call(acc[0], shell=True)\n\n# NOT reported\ndef handler():\n user = request.args.get(\"cmd\")\n acc = []\n acc.insert(0, user)\n subprocess.call(acc[0], shell=True)\n\n# NOT reported\ndef handler():\n user = request.args.get(\"cmd\")\n acc = []\n acc += [user]\n subprocess.call(acc[0], shell=True)\n```\n\n### Results\n\n`codeql database analyze \u003cdb> codeql/python-queries:Security/CWE-078/CommandInjection.ql`\n\n| construct | reported |\n|---|---|\n| `acc = [user]` | yes |\n| `acc.append(user)` | yes |\n| `acc.extend([user])` | **no** |\n| `acc.extend(other)` where `other = [user]` | **no** |\n| `acc.extend([user])` then `for x in acc:` | **no** |\n| `acc.insert(0, user)` | **no** |\n| `acc += [user]` | **no** |\n\n### Environment\n\n- CodeQL CLI **2.26.2** (bundle `codeql-bundle-osx64`), macOS arm64\n- query: shipped `Security/CWE-078/CommandInjection.ql`, unmodified\n- the same asymmetry appears with `Security/CWE-022/PathInjection.ql` and `Security/CWE-089/SqlInjection.ql`\n\n### Controls\n\n- `acc = [user]` and `acc.append(user)` **are** reported, so the query, source and sink all work on these files.\n- A variant where the value comes from a local constant instead of `request.args` is **not** reported, so the rule is source-dependent rather than firing on shape.\n- All files were present in the database source archive, so the silences are misses rather than unanalysed files.\n\n### Note\n\n`append` in Go is tracked as #14116. This is the Python analogue for the other three mutation forms.\n","author":{"url":"https://github.com/espressolee","@type":"Person","name":"espressolee"},"datePublished":"2026-08-10T01:47:23Z","url":"https://github.com/github/codeql/issues/22305"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1bd5c38-3cf8-02a4-3a20-5283f0148b9f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5AE:2284D2:58E28C:7B5728:6AF85841 |
| html-safe-nonce | 49d264d69d5c7564321c6e0968f4ce88dafa78b976a0f34a0171f4206234c248 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUFFOjIyODREMjo1OEUyOEM6N0I1NzI4OjZBRjg1ODQxIiwidmlzaXRvcl9pZCI6IjgyMTcwNDkwNDY0MzkxODg1NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b79687cae25e6e3578a8d9bf756555d16ac2f6aea0a800e6a7b9e7e6543a807e |
| hovercard-subject-tag | issue:5105857350 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/codeql/22305/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c21c9a4ea962968c2ca8f8eef068b924b6cbba14a96a3df6e09a2b5d1f35111a/github/codeql/issues/22305 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c21c9a4ea962968c2ca8f8eef068b924b6cbba14a96a3df6e09a2b5d1f35111a/github/codeql/issues/22305 |
| og:image:alt | Summary CodeQL's Python taint tracking propagates through list.append, but not through list.extend, list.insert, or += on a list. A security query therefore reports a flow written one way and stays... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | espressolee |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/github/codeql git https://github.com/github/codeql.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 143040428 |
| octolytics-dimension-repository_nwo | github/codeql |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143040428 |
| octolytics-dimension-repository_network_root_nwo | github/codeql |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width