Skip to content

fix(deps): update python-dotenv, pytest, and md2pdf to fix snyk vulne… - #46

Merged
mendsec merged 1 commit into
mainfrom
fix-snyk-develop
Jun 9, 2026
Merged

fix(deps): update python-dotenv, pytest, and md2pdf to fix snyk vulne…#46
mendsec merged 1 commit into
mainfrom
fix-snyk-develop

Conversation

@mendsec

@mendsec mendsec commented Jun 9, 2026

Copy link
Copy Markdown
Member

…rabilities

This commit addresses PR #27 failures by bumping versions to mitigate CVE-2025-71176, CVE-2026-28684, and transitive CVE-2025-68616 (WeasyPrint) & XSS in markdown2.

Added a remediation report in docs/reports/

PR Template

Tipo de Mudança

  • Bug fix (non-breaking change que corrige um problema)
  • Nova funcionalidade (non-breaking change que adiciona funcionalidade)
  • Breaking change (fix ou feature que faria com que a funcionalidade existente não funcionasse como esperado)
  • Melhoria de Documentação

Descrição

Descreva brevemente o que este PR faz.

Como foi testado?

  • Teste manual em ambiente de laboratório.
  • Validação via ksc_audit.py.
  • Markdown lint passou.

Checklist

  • Segui as diretrizes de contribuição.
  • Atualizei o CHANGELOG.md.
  • Testei em um servidor Rocky Linux 9 limpo.

Summary by CodeRabbit

  • Documentation

    • Added a Snyk vulnerabilities remediation report (Portuguese) describing identified issues and fixes.
  • Chores

    • Security-only updates to Python packages: pytest 8.1.1 → 9.0.3, python-dotenv 1.0.1 → 1.2.2, md2pdf 1.0.1 → 3.1.1 (keeps test/documentation compatibility)

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Three Python dependencies are upgraded in requirements.txt and a new Snyk remediation report documents the CI failure, vulnerability IDs, and confirms the updates are security-only with maintained compatibility.

Changes

Security Dependency Updates and Remediation

Layer / File(s) Summary
Dependency upgrades and remediation report
requirements.txt, docs/reports/snyk_vulnerabilities_remediation_report.md
Three Python dependencies are upgraded to address Snyk security vulnerabilities: pytest (8.1.1→9.0.3), python-dotenv (1.0.1→1.2.2), and md2pdf (1.0.1→3.1.1). A new remediation report documents the CI failure, referenced vulnerability IDs, and confirms security-only updates with maintained test and documentation compatibility.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Three packages spring to life so new,
Security fixes, tested and true,
Snyk's wisdom in the report so clear,
Dependencies patched, no more to fear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes an informative summary at the top addressing the specific CVEs and vulnerability mitigations, but the PR template sections below are unfilled with all checkboxes unchecked and placeholder text remaining. Complete the PR template by selecting the appropriate change type, filling in the description section, marking completed testing methods, and confirming checklist items completion.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly indicates the main change: updating three dependencies (python-dotenv, pytest, md2pdf) to fix Snyk vulnerabilities, which matches the changeset's core objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-snyk-develop

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/reports/snyk_vulnerabilities_remediation_report.md`:
- Around line 8-13: Update the pytest remediation entry to state the vulnerable
range precisely (vulnerable through 9.0.2 / CVE-2025-71176 affecting
TOCTOU/insecure temp dir handling) and clarify the compatibility claim: change
the sentence about "no breaking changes" to note that 9.0.3 is a bugfix release
with no breaking changes itself, but the upgrade path from 8.x crosses 9.0.0
which introduced breaking changes—so either confirm project compatibility via
testing or explicitly limit the claim to "pytest 9.0.3 contains no breaking
changes relative to 9.0.0" and recommend testing before upgrading from 8.1.1;
update the pytest section header and the "Ação Tomada" text accordingly.
- Around line 20-27: Update the report for the md2pdf upgrade to include
concrete evidence tying v3.1.1 to the claimed CVE and dependency upgrades: fetch
and cite md2pdf v3.1.1 release notes or changelog and the package
metadata/lockfile (pyproject.lock/poetry.lock/requirements.txt or setup.py)
showing the actual resolved versions of WeasyPrint, markdown2 and Pillow; verify
and state that the public API call pattern (e.g., md2pdf(pdf_path,
md_file_path=...)) remains compatible with 3.1.1 by referencing the changelog or
simple usage example from the release, and explicitly reconcile whether Pillow’s
flagged issue is still present by listing its resolved version or remaining
vulnerability status.
- Around line 14-19: Update the python-dotenv entry to clarify that
CVE-2026-28684 affects write/edit operations (functions that rewrite .env such
as set_key/unset_key) and not read-only usage via load_dotenv; state that this
repo pins python-dotenv==1.2.2 in requirements.txt and that a code search shows
no usages of set_key or unset_key so the vulnerability is not applicable for
read-only loading, and add a note to verify/mention the absence of
set_key/unset_key calls in the codebase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 41684a46-265d-4c25-bac2-18ea2fbf38e6

📥 Commits

Reviewing files that changed from the base of the PR and between d7f73a8 and 34bbe1e.

📒 Files selected for processing (2)
  • docs/reports/snyk_vulnerabilities_remediation_report.md
  • requirements.txt

Comment on lines +8 to +13
### 1. `pytest`
- **Versão Anterior:** 8.1.1
- **Vulnerabilidade:** CVE-2025-71176 (Uso inseguro de diretórios temporários, permitindo DoS local ou escalonamento de privilégios).
- **Versão Atualizada:** 9.0.3
- **Ação Tomada:** Atualização da versão para mitigar a vulnerabilidade.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

CVE-2025-71176 pytest temporary directory vulnerability

💡 Result:

CVE-2025-71176 is a security vulnerability in the pytest framework affecting versions up to and including 9.0.2 [1][2][3]. The vulnerability stems from pytest's use of a predictable naming pattern, /tmp/pytest-of-{user}, for its base temporary directory on UNIX systems [2][4][5]. Because this directory name is predictable, it is susceptible to local symlink attacks and Time-of-Check to Time-of-Use (TOCTOU) race conditions [6][4][5]. An attacker on a multi-user system could pre-create a malicious symlink or directory at that path, potentially leading to denial of service, unauthorized file access, or privilege escalation [1][2][5]. This issue was addressed in the pytest repository through two primary efforts: 1. A comprehensive fix (PR #14279) introduced the use of randomly-named root directories generated via tempfile.mkdtemp, eliminating the predictable path entirely, and implemented file-descriptor-based ownership checks to prevent TOCTOU races [6]. 2. A simpler, backportable fix (PR #14343) was merged to explicitly stop following symlinks and reject them if they are detected at the base temporary path, providing a remediation that was easier to include in maintenance releases [7][8][9]. Users are advised to upgrade to pytest 9.0.3 or later to remediate this vulnerability [1][10]. As a temporary mitigation, administrators on affected systems can rely on kernel-level protections (such as setting fs.protected_symlinks = 1 on Linux) or manually define a secure temporary directory using environment variables like PYTEST_DEBUG_TEMPROOT [10][4][5].

Citations:


🌐 Web query:

pytest 9.0.3 release notes breaking changes

💡 Result:

Pytest 9.0.3, released on April 7, 2026, is a bug-fix release designed as a drop-in replacement [1][2][3]. It contains no breaking changes [1]. While it does not introduce breaking changes, it does include one notable behavior change regarding plugin loading: Blocking a conftest.py file using the -p no: option is now explicitly disallowed [4][3]. Previously, this action could cause an internal assertion failure during plugin loading. Pytest 9.0.3 now raises a clear UsageError, explaining that conftest files are not plugins and cannot be disabled via the -p flag [4][3]. Additionally, this release includes a fix for an insecure temporary directory issue (CVE-2025-71176) [4][3]. If you are looking for breaking changes in the 9.x release cycle, those were primarily introduced in pytest 9.0.0, which included drops in Python 3.9 support, changes to how overlapping test arguments are handled, and making PytestRemovedIn9Warning deprecation warnings errors by default [5][6][7].

Citations:


Fix/clarify pytest remediation entry (CVE + compatibility)

  • CVE-2025-71176 is correctly attributed to pytest and covers insecure/TOCTOU-prone temporary directory handling on UNIX (symlink/race issues); the vulnerable range is up to and including 9.0.2, so upgrading 8.1.1 → 9.0.3 is an appropriate fix.
  • pytest 9.0.3 is a drop-in bugfix release with no breaking changes, but the 8.x → 9.x upgrade crosses 9.0.0, which introduced breaking changes; the report should either cite tested compatibility for the project or explicitly limit the compatibility claim to “9.0.3 has no breaking changes.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reports/snyk_vulnerabilities_remediation_report.md` around lines 8 - 13,
Update the pytest remediation entry to state the vulnerable range precisely
(vulnerable through 9.0.2 / CVE-2025-71176 affecting TOCTOU/insecure temp dir
handling) and clarify the compatibility claim: change the sentence about "no
breaking changes" to note that 9.0.3 is a bugfix release with no breaking
changes itself, but the upgrade path from 8.x crosses 9.0.0 which introduced
breaking changes—so either confirm project compatibility via testing or
explicitly limit the claim to "pytest 9.0.3 contains no breaking changes
relative to 9.0.0" and recommend testing before upgrading from 8.1.1; update the
pytest section header and the "Ação Tomada" text accordingly.

Comment thread docs/reports/snyk_vulnerabilities_remediation_report.md
Comment on lines +20 to +27
### 3. `md2pdf`
- **Versão Anterior:** 1.0.1
- **Vulnerabilidade:** Vulnerabilidades transitivas através de dependências defasadas:
- **WeasyPrint** (CVE-2025-68616): Falha de Server-Side Request Forgery (SSRF) permitindo que requisições bypassassem políticas de segurança.
- **markdown2**: Múltiplas vulnerabilidades de Cross-Site Scripting (XSS).
- **Versão Atualizada:** 3.1.1
- **Ação Tomada:** A versão 1.0.1 do `md2pdf` não possuía travas atualizadas para dependências seguras. A atualização para a versão 3.1.1 garantiu a utilização de versões modernas e seguras do WeasyPrint e do markdown2.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

md2pdf 3.1.1 changelog breaking changes API

💡 Result:

md2pdf v3.1.1 (jmaupetit/md2pdf) has no breaking changes to its API documented in the 3.1.1 changelog; it only contains a security fix. The upstream changelog shows 3.1.1 dated 2026-03-31 under “Security” with the entry “Upgrade pygments to 2.20+” and does not list any “Changed/Removed” items or any notes labeled as breaking/API changes for 3.1.1 [1]. For context, the changelog and releases do record breaking changes, but they are associated with version 3.0.0 (not 3.1.1). In the releases page, v3.0.0 includes “[BC]” items such as switching to Typer and “CLI: moved to a no-arguments command (only options)” and “Add dependency groups to handle project flavors (cli and latex) [BC]” [2].

Citations:


🏁 Script executed:

#!/bin/bash
# Test md2pdf 3.1.1 API compatibility with existing usage pattern
python3 -m venv /tmp/test_md2pdf_api
source /tmp/test_md2pdf_api/bin/activate
pip install --quiet md2pdf==3.1.1

# Test if the API signature still works
python3 << 'PYEOF'
try:
    from md2pdf.core import md2pdf
    import inspect
    sig = inspect.signature(md2pdf)
    print(f"✓ md2pdf.core.md2pdf signature: {sig}")
    params = list(sig.parameters.keys())
    if 'pdf_file_path' in params or 'md_file_path' in params:
        print("✓ Expected parameters found")
    else:
        print(f"⚠ Parameters changed: {params}")
except ImportError as e:
    print(f"✗ Import failed: {e}")
except Exception as e:
    print(f"✗ Error: {e}")
PYEOF

deactivate
rm -rf /tmp/test_md2pdf_api

Repository: portosoft/ksc-deployment-runbook

Length of output: 1828


md2pdf 1.0.1 → 3.1.1: API-safe, but CVE/dependency remediation claims need evidence

  • Upstream md2pdf v3.1.1 changelog shows no breaking/API-breaking changes for 3.1.1 (breaking items are associated with 3.0.0), so the existing call style like md2pdf(pdf_path, md_file_path=...) is unlikely to break due to this upgrade.
  • The report’s claim that md2pdf 3.1.1 fixes WeasyPrint CVE-2025-68616 (SSRF) and pulls in “secure versions” of WeasyPrint/markdown2 (and Pillow) is not evidenced by the gathered results; add concrete proof by tying md2pdf 3.1.1’s resolved dependency versions to the CVE fix (and reconcile with the already-flagged Pillow issue).
🧰 Tools
🪛 LanguageTool

[style] ~22-~22: Para conferir mais clareza ao seu texto, busque usar uma linguagem mais concisa.
Context: ...ilidade:** Vulnerabilidades transitivas através de dependências defasadas: - **WeasyPrin...

(ATRAVES_DE_POR_VIA)


[locale-violation] ~23-~23: “Server” é um estrangeirismo. É preferível dizer “servidor”.
Context: ...WeasyPrint** (CVE-2025-68616): Falha de Server-Side Request Forgery (SSRF) permitindo ...

(PT_BARBARISMS_REPLACE_SERVER)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reports/snyk_vulnerabilities_remediation_report.md` around lines 20 -
27, Update the report for the md2pdf upgrade to include concrete evidence tying
v3.1.1 to the claimed CVE and dependency upgrades: fetch and cite md2pdf v3.1.1
release notes or changelog and the package metadata/lockfile
(pyproject.lock/poetry.lock/requirements.txt or setup.py) showing the actual
resolved versions of WeasyPrint, markdown2 and Pillow; verify and state that the
public API call pattern (e.g., md2pdf(pdf_path, md_file_path=...)) remains
compatible with 3.1.1 by referencing the changelog or simple usage example from
the release, and explicitly reconcile whether Pillow’s flagged issue is still
present by listing its resolved version or remaining vulnerability status.

…rabilities

This commit addresses PR #27 failures by bumping versions to mitigate CVE-2025-71176, CVE-2026-28684, and transitive CVE-2025-68616 (WeasyPrint) & XSS in markdown2.

Added a remediation report in docs/reports/
@mendsec
mendsec force-pushed the fix-snyk-develop branch from 34bbe1e to 73883fa Compare June 9, 2026 17:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docs/reports/snyk_vulnerabilities_remediation_report.md (1)

26-26: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not assert Pillow remediation without resolved-version evidence.

The sentence claiming Pillow vulnerabilities were resolved is still not substantiated by dependency-resolution evidence in this PR context, while static analysis continues to flag critical Pillow findings. Please either (a) add concrete resolved versions/proof from lock/dependency metadata, or (b) soften this to a verification statement instead of a definitive remediation claim.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reports/snyk_vulnerabilities_remediation_report.md` at line 26, The
remediation statement in the "Ação Tomada" paragraph asserts that Pillow
vulnerabilities were resolved without providing dependency-resolution evidence;
either update that paragraph to include concrete resolved versions and proof
(e.g., add the Pillow resolved version and a reference to the
lockfile/poetry.lock / pipfile.lock metadata showing the resolved tree for
md2pdf v3.1.1) or change the phrasing to a verification-style statement (e.g.,
"checks indicate the upgrade should address known Pillow issues; see lockfile
for resolved versions") — edit the sentence that currently mentions Pillow and
md2pdf v3.1.1 accordingly to include the chosen proof or to soften the claim.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/reports/snyk_vulnerabilities_remediation_report.md`:
- Line 26: The remediation statement in the "Ação Tomada" paragraph asserts that
Pillow vulnerabilities were resolved without providing dependency-resolution
evidence; either update that paragraph to include concrete resolved versions and
proof (e.g., add the Pillow resolved version and a reference to the
lockfile/poetry.lock / pipfile.lock metadata showing the resolved tree for
md2pdf v3.1.1) or change the phrasing to a verification-style statement (e.g.,
"checks indicate the upgrade should address known Pillow issues; see lockfile
for resolved versions") — edit the sentence that currently mentions Pillow and
md2pdf v3.1.1 accordingly to include the chosen proof or to soften the claim.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0865baf1-bea4-414b-bd28-99ec022ff2b9

📥 Commits

Reviewing files that changed from the base of the PR and between 34bbe1e and 73883fa.

📒 Files selected for processing (2)
  • docs/reports/snyk_vulnerabilities_remediation_report.md
  • requirements.txt

@mendsec
mendsec merged commit 0ec5df0 into main Jun 9, 2026
7 checks passed
@mendsec
mendsec deleted the fix-snyk-develop branch June 15, 2026 04:10
mendsec added a commit that referenced this pull request Jun 15, 2026
fix(deps): update python-dotenv, pytest, and md2pdf to fix snyk vulne…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant