CVE-2021-41134
📋 TL;DR
CVE-2021-41134 is a stored cross-site scripting (XSS) vulnerability in nbdime, a tool for diffing and merging Jupyter Notebooks. Attackers can inject malicious scripts into notebook filenames that execute when users view diffs, potentially stealing session cookies or performing unauthorized actions. Users of affected nbdime versions who view notebook diffs are vulnerable.
💻 Affected Systems
- nbdime
📦 What is this software?
Nbdime by Jupyter
Nbdime by Jupyter
Nbdime by Jupyter
Nbdime by Jupyter
Nbdime by Jupyter
⚠️ Risk & Real-World Impact
Worst Case
Attackers could steal user session cookies, hijack accounts, perform unauthorized actions in Jupyter environments, or redirect users to malicious sites.
Likely Case
Session hijacking leading to unauthorized access to Jupyter notebooks and data, or defacement of the diff interface.
If Mitigated
No impact if proper input sanitization is implemented or if users don't view diffs of malicious notebooks.
🎯 Exploit Status
Exploitation requires ability to create or rename notebook files with malicious payloads in filenames, then trick users into viewing diffs.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Versions after commit e44a5cc7677f24b45ebafc756db49058c2f750ea
Vendor Advisory: https://github.com/jupyter/nbdime/security/advisories/GHSA-p6rw-44q7-3fw4
Restart Required: No
Instructions:
1. Update nbdime to latest version using pip: 'pip install --upgrade nbdime' 2. Verify installation with 'nbdime --version' 3. No restart required as it's a Python package.
🔧 Temporary Workarounds
Avoid viewing diffs of untrusted notebooks
allDo not use diffNotebookCheckpoint function on notebooks from untrusted sources
Sanitize notebook filenames
allImplement custom filename validation to remove HTML/script tags before processing
🧯 If You Can't Patch
- Implement web application firewall (WAF) rules to block XSS payloads in filenames
- Restrict user permissions to prevent malicious notebook file creation/renaming
🔍 How to Verify
Check if Vulnerable:
Check nbdime version: 'nbdime --version' and compare to patched versions. If using source, check for commit e44a5cc7677f24b45ebafc756db49058c2f750ea.
Check Version:
nbdime --version
Verify Fix Applied:
After update, test by creating a notebook with XSS payload in filename and verifying diff view doesn't execute scripts.
📡 Detection & Monitoring
Log Indicators:
- Unusual notebook filenames containing script tags or JavaScript code
- Multiple failed diff operations
Network Indicators:
- Outbound connections to suspicious domains after viewing notebook diffs
SIEM Query:
filename:*<script* OR filename:*javascript:* AND process:nbdime
🔗 References
- https://github.com/jupyter/nbdime/commit/e44a5cc7677f24b45ebafc756db49058c2f750ea
- https://github.com/jupyter/nbdime/security/advisories/GHSA-p6rw-44q7-3fw4
- https://github.com/jupyter/nbdime/commit/e44a5cc7677f24b45ebafc756db49058c2f750ea
- https://github.com/jupyter/nbdime/security/advisories/GHSA-p6rw-44q7-3fw4