Skip to content

[Security] Automated static analysis findings for statsmodels/statsmodels (academic research) #10527

Open

Description

@fcas

Hello maintainers,

We are reaching out as part of an academic study on software security in the open-source Artificial Intelligence (AI) supply chain. As part of this study, we ran automated static analysis on statsmodels/statsmodels and would like to share the aggregated results with you, so that the project can verify them and act if needed.

Context of the research

This analysis is part of the doctoral thesis "Reducing Software Vulnerabilities in the Artificial Intelligence Supply Chain", developed under a joint supervision (cotutelle) between:

  • Universidade de São Paulo (USP): Programa de Pós-Graduação em Sistemas de Informação (PPgSI), Escola de Artes, Ciências e Humanidades (EACH), Brazil;
  • Nantes Université: LS2N (UMR CNRS 6004), NaoMod team, France.

Researchers:

  • Felipe Cordeiro Alves Dias, PhD candidate (USP / Nantes Université);
  • Prof. Dr. Daniel de Angelis Cordeiro, advisor (EACH-USP);
  • Prof. Dr. Gerson Sunyé, co-advisor (Nantes Université, LS2N / NaoMod).

The methodology and the first results of this study were published at the XXII Brazilian Symposium on Information Systems (SBSI 2026):
https://sol.sbc.org.br/index.php/sbsi/article/view/41368

What we did

On 2026-08-16, a fork of this repository, synchronized with the upstream default branch, was analyzed with GitHub CodeQL (source code), GitHub Dependabot (declared dependencies) and Semgrep Supply Chain (dependencies, including a reachability verdict). The scope is limited to Python: only CodeQL's Python analysis, Python (pip/PyPI) dependencies, and files present in the upstream repository are reported; code in other languages (e.g., C/C++) was not assessed. The only exception is possibly exposed credentials, which are reported regardless of language. No code was executed against any deployment of the project, and no exploitation was attempted.

Aggregated findings

Tool What it analyzes Open findings By severity
CodeQL Python source code 26 6 critical / 20 high
Dependabot declared Python dependencies 0 -
Semgrep Supply Chain Python dependencies, with reachability 0 (0 reachable) -

Evidence

  • Snapshot of the analysis data: 2026-08-16
  • Analyzed commit(s) of the upstream code: f4b410b95843
  • Each identifier below links to its public reference (NVD/GitHub Advisory Database, MITRE CWE, MITRE CAPEC, MITRE ATT&CK, OWASP).
  • CAPEC and ATT&CK entries are derived from the CWEs found, through MITRE's own mappings (CAPEC Related_Weaknesses and Taxonomy_Mappings); they describe how such weaknesses are typically exploited, not attacks observed against this project.

Findings by security standard

CVE / GHSA: vulnerabilities in declared dependencies: none
CWE: weakness types (11)
CAPEC: attack patterns related to the CWEs above (31)
  • CAPEC-6: Argument Injection (likelihood: High, severity: High); via CWE-78
  • CAPEC-10: Buffer Overflow via Environment Variables (likelihood: High, severity: High); via CWE-99
  • CAPEC-13: Subverting Environment Variable Values (likelihood: High, severity: Very High); via CWE-73
  • CAPEC-15: Command Delimiters (likelihood: High, severity: High); via CWE-78
  • CAPEC-35: Leverage Executable Code in Non-Executable Files (likelihood: High, severity: Very High); via CWE-94, CWE-95
  • CAPEC-41: Using Meta-characters in E-mail Headers to Inject Malicious Payloads (likelihood: High, severity: High); via CWE-88
  • CAPEC-43: Exploiting Multiple Input Interpretation Layers (likelihood: Medium, severity: High); via CWE-78
  • CAPEC-64: Using Slashes and URL Encoding Combined to Bypass Validation Logic (likelihood: High, severity: High); via CWE-22, CWE-73
  • CAPEC-72: URL Encoding (likelihood: High, severity: High); via CWE-73
  • CAPEC-73: User-Controlled Filename (likelihood: High, severity: High); via CWE-116
  • CAPEC-75: Manipulating Writeable Configuration Files (likelihood: High, severity: Very High); via CWE-99
  • CAPEC-76: Manipulating Web Input to File System Calls (likelihood: High, severity: Very High); via CWE-22, CWE-23, CWE-73
  • CAPEC-77: Manipulating User-Controlled Variables (likelihood: High, severity: Very High); via CWE-94
  • CAPEC-78: Using Escaped Slashes in Alternate Encoding (likelihood: High, severity: High); via CWE-22, CWE-73
  • CAPEC-79: Using Slashes in Alternate Encoding (likelihood: High, severity: High); via CWE-22, CWE-73
  • CAPEC-80: Using UTF-8 Encoding to Bypass Validation Logic (likelihood: High, severity: High); via CWE-73
  • CAPEC-81: Web Server Logs Tampering (likelihood: Medium, severity: High); via CWE-116
  • CAPEC-85: AJAX Footprinting (likelihood: High, severity: Low); via CWE-116
  • CAPEC-88: OS Command Injection (likelihood: High, severity: High); via CWE-78, CWE-88
  • CAPEC-104: Cross Zone Scripting (likelihood: Medium, severity: High); via CWE-116
  • CAPEC-108: Command Line Execution through SQL Injection (likelihood: Low, severity: Very High); via CWE-78
  • CAPEC-126: Path Traversal (likelihood: High, severity: Very High); via CWE-22
  • CAPEC-137: Parameter Injection (likelihood: Medium, severity: Medium); via CWE-88
  • CAPEC-139: Relative Path Traversal (likelihood: High, severity: High); via CWE-23
  • CAPEC-174: Flash Parameter Injection (likelihood: High, severity: Medium); via CWE-88
  • CAPEC-240: Resource Injection (likelihood: High, severity: High); via CWE-99
  • CAPEC-242: Code Injection (likelihood: High, severity: High); via CWE-94
  • CAPEC-267: Leverage Alternate Encoding (likelihood: High, severity: High); via CWE-73
  • CAPEC-460: HTTP Parameter Pollution (HPP) (likelihood: n/a, severity: Medium); via CWE-88
  • CAPEC-586: Object Injection (likelihood: Medium, severity: High); via CWE-502
  • CAPEC-597: Absolute Path Traversal (likelihood: n/a, severity: n/a); via CWE-36
MITRE ATT&CK: techniques related to the CAPECs above (7)
  • T1027: Obfuscated Files or Information; via CAPEC-267
  • T1027.006: HTML Smuggling; via CAPEC-35
  • T1027.009: Embedded Payloads; via CAPEC-35
  • T1562.003: n/a; via CAPEC-13
  • T1564.009: Resource Forking; via CAPEC-35
  • T1574.006: Dynamic Linker Hijacking; via CAPEC-13
  • T1574.007: Path Interception by PATH Environment Variable; via CAPEC-13
OWASP Top 10: risk categories (Semgrep rule metadata): none

Automated tools produce false positives, and a vulnerable dependency is not necessarily exploitable in this project's context (see the reachability column). These numbers should be read as candidates for verification, not as confirmed vulnerabilities.

Recommendations

  1. Verify the findings above; we can share the detailed list privately on request.
  2. Check the latest security reports and advisories relevant to the project's dependencies, such as the GitHub Advisory Database, the NVD, OSV.dev and the OWASP Top 10 for LLM Applications.
  3. If not yet enabled, consider enabling Dependabot alerts, code scanning, secret scanning and Private Vulnerability Reporting in the repository settings.

Ethical principles

  • Defensive purpose only. The goal is to help improve the security of the AI ecosystem; the fork was used exclusively for static analysis.
  • No exploitation. No finding was tested against running systems, and no attempt was made to validate credentials or access third-party services.
  • Responsible disclosure. Sensitive details (file paths, line numbers, exploit conditions, and anything related to credentials) are never posted publicly. This report is sent through the repository itself: privately, through GitHub Private Vulnerability Reporting, whenever the project has it enabled, and as a public issue only otherwise.
  • Aggregated publication. Research outputs report results only in aggregated or anonymized form, and never disclose secret values.
  • Voluntary participation. Maintainers are under no obligation to reply. If you prefer not to receive further contact about this study, just say so in this thread and we will not contact you again.

Thank you for maintaining this project. If you have questions about this analysis, you can reply here or contact us at [email protected].

Felipe Cordeiro Alves Dias, on behalf of the research team

Activity

  1. bashtage commented on Oct 22, 2026

    @bashtage
    Member

    I'm not exactly sure what the purpose of this post is. We readily admit that we use pickle and everyone knows that pickle is unsafe in untrusted environments.

    Is there any reasonable action that is needed from this?

  2. fcas commented on Oct 22, 2026

    @fcas
    Author

    Thanks for asking, @bashtage. The purpose is informational: this notice is part of an academic study that returns automated static-analysis results to the AI/ML libraries it analyzed. No specific action is required. The results are candidates for verification, not confirmed vulnerabilities, and many may well be false positives or known, documented behavior, like the use of pickle you mention.

    For completeness, besides the single py/unsafe-deserialization alert, the report contains 25 other CodeQL alerts in Python code: 20 py/path-injection, 3 py/code-injection, and 2 py/command-line-injection. Our configuration also treats local inputs (files, environment variables, command-line arguments) as user-provided, which tends to flag code that is safe in a library context. If it would help, I can list each alert here with its location; otherwise, please feel free to close this issue.

  3. bashtage commented on Oct 22, 2026

    @bashtage
    Member

    Thanks. It would help to have a list and locations so we can decide if they are by design (e.g., pickle) or some form of unnecessary omission (or often legacy and no longer needed).

  4. fcas commented on Oct 22, 2026

    @fcas
    Author

    Sure, @bashtage, here is the full list (26 CodeQL alerts, Python analysis only, on a fork synchronized with main in August 2026; line numbers refer to that version). Our configuration treated local inputs (files, environment variables, command-line arguments) as user-provided, so many of these are expected to be by design.

    CodeQL query Severity (CodeQL) Location
    py/code-injection critical archive/examples/run_all.py:35
    py/code-injection critical examples/run_all.py:37
    py/code-injection critical statsmodels/examples/run_all.py:71
    py/command-line-injection critical statsmodels/tsa/x13.py:96
    py/command-line-injection critical statsmodels/tsa/x13.py:160
    py/path-injection high archive/docs/fix_longtable.py:9
    py/path-injection high archive/docs/fix_longtable.py:10
    py/path-injection high archive/docs/fix_longtable.py:20
    py/path-injection high archive/docs/fix_longtable.py:21
    py/path-injection high archive/docs/fix_longtable.py:21
    py/path-injection high statsmodels/_build/git_version.py:60
    py/path-injection high statsmodels/_build/tempita.py:21
    py/path-injection high statsmodels/datasets/utils.py:311
    py/path-injection high statsmodels/tsa/ardl/_pss_critical_values/pss_process.py:20
    py/path-injection high tools/export_notebooks_to_python.py:95
    py/path-injection high tools/export_notebooks_to_python.py:96
    py/path-injection high tools/export_notebooks_to_python.py:112
    py/path-injection high tools/export_notebooks_to_python.py:116
    py/path-injection high tools/export_notebooks_to_python.py:117
    py/path-injection high tools/export_notebooks_to_python.py:138
    py/path-injection high tools/export_notebooks_to_python.py:161
    py/path-injection high tools/generate_formula_api.py:68
    py/path-injection high tools/generate_formula_api.py:81
    py/path-injection high tools/releasing/enumerate-api.py:258
    py/path-injection high tools/releasing/enumerate-api.py:261
    py/unsafe-deserialization critical archive/examples/thirdparty/ex_ratereturn.py:22

    A note on how these were produced: the alerts come from CodeQL's Python analysis, but in our study they are not used raw. Each finding is mapped onto a cybersecurity knowledge graph that links it to open security standards: CWE (weakness type, with its full hierarchy), CVE and GitHub advisories (GHSA), CPE (affected platform), CVSS and EPSS (severity and exploitation likelihood), CAPEC (attack patterns), MITRE ATT&CK (techniques) and OWASP Top 10 (risk category), plus Semgrep's reachability verdict for dependencies. This is what we use to prioritize and reduce noise at the corpus level; for a single project, a maintainer's knowledge of the design, as in your pickle example, remains the decisive filter.

    We have not validated any of them. Thank you for taking a look, and feel free to close the issue whenever it suits you.

  5. ChadFulton commented on Oct 22, 2026

    @ChadFulton
    Member

    @bashtage probably has more informed views on this, but I would find this kind of analysis more helpful if there was some discussion of what relevant attack vectors we might be concerned about as developers of a library.

    For example, it's clear that examples/run_all.py:37 does a blind exec on the code from any python file found in the python subdirectory. So, yes, it is exactly code-injection.

    But the example case on the CodeQL website (https://codeql.github.com/codeql-query-help/python/py-code-injection/) is about blindly executing code that was given in a POST request. From a brief look, it seems that many of the codeql injection examples are about data submitted via web forms.

    So what I would find very useful from security researchers such as yourselves is a view on whether any of these suggestions even have the potential to apply to a library that is not running a web server and where presumably all input is given by a user who already has the ability to run arbitrary code on their machine?

    I'm not asking you to evaluate individual cases in our specific code, but if you could give a sense of what kinds of threats a library should be thinking about, that would make this kind of analysis much more useful to me.

  6. fcas commented on Oct 22, 2026

    @fcas
    Author

    Thank you, @ChadFulton, this is a fair and important point.

    Short answer: for a library that runs no server, an alert like examples/run_all.py:37 only matters if the data reaching the sink can come from someone other than the person running the code. If the input always comes from that person, executing it gives them nothing they could not already do, so there is no trust boundary to cross and it is not a vulnerability. CodeQL's injection queries are written mostly with web applications in mind. Our configuration also counted local sources (files, environment variables, command-line arguments) as user-provided, which flags many such by-design cases. That is a limitation of our report.

    Where a library can still be on a trust boundary, these are the threats we would suggest thinking about:

    1. Downstream services. A library function may end up behind someone else's web API. Inputs that applications typically take from end users are then exposed: file names, dataset names, formula or expression strings, model or result files. If a function evaluates or executes its input (formula strings that allow Python expressions, eval/exec, unpickling), stating "trusted input only" in the docstring helps downstream developers avoid exposing it.
    2. Untrusted artifacts. Loading pickled models or results that were downloaded or shared by others is the classic case: the risk is not in your code, but in users unpickling files they did not produce. Documenting this and offering a safe format where possible is the usual mitigation.
    3. Remote data and caches. When the library downloads data, as dataset helpers do, file paths or cache entries built from remote content can matter, along with the integrity of what is fetched. A shared or world-writable cache directory turns "local" files into input from other users.
    4. CI and maintenance scripts. These run with repository secrets. Inputs from pull requests, branch names or environment variables can cross a boundary there even when they never do in the library itself.
    5. Dependencies. A vulnerable dependency matters when the library's own code reaches the vulnerable function; reachability analysis helps tell those cases apart.

    Writing these trust assumptions down, for example in a short threat-model section of SECURITY.md, also makes reports like ours much easier to triage: each alert can be checked against the boundaries the project considers in scope.

    Your question is also a result for our study: it shows that, without the project's own threat model, even filtered and prioritized findings leave the hardest step to the maintainers. Thank you for taking the time to write it.

  7. ChadFulton commented on Oct 22, 2026

    @ChadFulton
    Member

    Thank you for the follow-up, that's a useful set of things to think about! Documenting the known insecure points in a SECURITY.md file also makes a lot of sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions