Security fixes: - Remove external CDN sources from CSP (cdn.jsdelivr.net, cdnjs.cloudflare.com) - Add path validation functions to prevent path traversal attacks - Block access to sensitive system directories - Add isPathAccessible() check for file operations UI/Accessibility fixes: - Increase tab close button from 16px to 24px for better touch targets - Add focus-visible styles for keyboard navigation - Add ARIA labels to all toolbar buttons - Add aria-hidden="true" to decorative SVG icons - Add role="tablist" and role="tab" to tab bar - Fix duplicate font-size declaration in .preview-content Reports generated: - Security vulnerability scan (10 findings) - STRIDE threat model with MITRE ATT&CK mapping - Comprehensive UI design review (40 issues) Amit Haridas
18 KiB
Security Assessment Report: MarkdownConverter v4.0.0
Assessment Date: 2026-03-15 Application: MarkdownConverter - Electron-based Markdown editor and document converter Target Version: 4.0.0 Assessor: Security Audit Agent
Executive Summary
This assessment identified 10 security findings ranging from Critical to Low severity. The most significant concerns involve insecure Electron security configuration that could allow XSS attacks to escalate to full system access, arbitrary code execution via the REPL feature, and missing input validation on file operations.
| Severity | Count |
|---|---|
| Critical | 2 |
| High | 3 |
| Medium | 3 |
| Low | 2 |
Vulnerability Findings
CVE-MC-001: Insecure Electron Security Configuration (Critical)
CVSS 3.1 Score: 9.6 (Critical) CWE-265: CWE-1021: Improper Restriction of Renderers
Location: src/main.js (lines 328-332)
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
spellcheck: true
},
Description:
The main application window has nodeIntegration: true and contextIsolation: false, which is the most insecure Electron configuration. This allows the renderer process direct access to Node.js APIs, meaning any XSS vulnerability in the markdown rendering or external content could lead to full system compromise.
Exploitability:
- An attacker who can inject malicious JavaScript (via markdown files, XSS in preview, or compromised dependencies) gains immediate access to:
- Full file system read/write via
fsmodule - Command execution via
child_process - Network access via
netmodule - All system resources
- Full file system read/write via
Attack Scenario:
- User opens a malicious markdown file containing embedded JavaScript
- The JavaScript executes in the renderer with full Node.js access
- Attacker can read sensitive files, execute commands, exfiltrate data
Remediation:
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
sandbox: true,
preload: path.join(__dirname, 'preload.js')
}
Note: The preload.js file already implements a secure IPC bridge but it is not being utilized for the main window.
CVE-MC-002: Arbitrary Code Execution via REPL Feature (Critical)
CVSS 3.1 Score: 9.3 (Critical) CWE-94: Improper Control of Generation of Code ('Code Injection')
Location: src/main.js (lines 4369-4396)
Description:
The execute-code IPC handler allows execution of arbitrary Python and Bash scripts through the REPL panel. While JavaScript execution appears to have been removed or limited, Python and Bash commands are executed via execFile with user-supplied code.
Vulnerable Code Pattern:
ipcMain.handle('execute-code', async (event, { code, language }) => {
// ...
if (language === 'python' || language === 'py') {
cmd = 'python';
args = ['-c', code];
}
// ...
execFile(cmd, args, { timeout }, (err, stdout, stderr) => {
// ...
});
});
Exploitability:
- Users can be tricked into running malicious code blocks
- Markdown files can contain executable code blocks with "Run" buttons
- No sandboxing or permission restrictions on executed code
Attack Scenario:
- Attacker creates markdown file with malicious Python code block
- User clicks "Run" button in preview
- Python code executes with user's full permissions
- Attacker gains code execution on victim's machine
Remediation:
- Remove arbitrary code execution feature entirely, OR
- Implement strict sandboxing (Docker, VM, or restricted Python environment)
- Add user confirmation dialogs with clear warnings
- Execute in isolated environment with no filesystem/network access
- Implement allowlist of safe operations
CVE-MC-003: Potential XSS in Markdown Rendering (High)
CVSS 3.1 Score: 8.0 (High) CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Location: src/renderer.js (lines 387-419)
Description: While DOMPurify is used to sanitize HTML, several extensions to marked.js may bypass sanitization:
- Custom Admonition Extension (lines 51-77):
marked.use({
extensions: [{
name: 'admonition',
// ...
renderer(token) {
const inner = this.parser.parse(token.text);
return `<div class="admonition admonition-${token.admonitionType}">
<div class="admonition-title">${icon} ${token.admonitionType...}</div>
<div class="admonition-content">${inner}</div>
</div>`;
}
}]
});
- innerHTML Assignments (line 419):
preview.innerHTML = sanitizedHtml;
Exploitability:
- Combined with CVE-MC-001, XSS leads to full system compromise
- Custom markdown extensions may not be properly sanitized
- Admonition type is directly interpolated into HTML without escaping
Remediation:
- Ensure all custom markdown extensions escape user input
- Add Content Security Policy that blocks inline scripts
- Use
textContentinstead ofinnerHTMLwhere possible - Audit all custom marked.js extensions for XSS vectors
CVE-MC-004: Missing Path Traversal Protection (High)
CVSS 3.1 Score: 7.8 (High) CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Location: src/main.js (lines 4241-4281)
Description:
The list-directory and open-file-path IPC handlers accept arbitrary file paths without validation:
ipcMain.handle('list-directory', async (event, dirPath) => {
try {
if (!dirPath) { /* dialog */ }
// No path validation - accepts any path
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
// ...
}
});
ipcMain.on('open-file-path', (event, filePath) => {
// No path validation
if (!fs.existsSync(filePath)) return;
const content = fs.readFileSync(filePath, 'utf-8');
mainWindow.webContents.send('file-opened', { path: filePath, content });
});
Exploitability:
- Malicious renderer code can read any file on the system
- No restriction to a sandbox directory
- Combined with XSS, attacker can exfiltrate sensitive files
Remediation:
const ALLOWED_DIRECTORIES = [app.getPath('documents'), app.getPath('desktop')];
function isPathAllowed(filePath) {
const resolved = path.resolve(filePath);
return ALLOWED_DIRECTORIES.some(dir => resolved.startsWith(dir));
}
CVE-MC-005: Weak Content Security Policy (High)
CVSS 3.1 Score: 7.5 (High) CWE-1021: Improper Restriction of Renderers
Location: src/index.html (line 5)
<meta http-equiv="Content-Security-Policy" content="default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net;
style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com;
img-src 'self' data: blob: file:;
font-src 'self' data:;
connect-src 'self' https://www.plantuml.com;">
Description: The CSP contains several security weaknesses:
'unsafe-inline'in script-src - Allows inline script injection'unsafe-eval'in script-src - Allowseval()and similar functionshttps://cdn.jsdelivr.net- Allows scripts from external CDN (supply chain risk)file:in img-src - Allows loading local files as images (potential information disclosure)
Exploitability:
- XSS attacks can execute arbitrary scripts
- External CDN compromise could inject malicious code
eval()enables dynamic code execution
Remediation:
- Remove
'unsafe-inline'and'unsafe-eval' - Use nonces or hashes for inline scripts
- Remove external CDNs or use Subresource Integrity (SRI)
- Remove
file:from img-src
CVE-MC-006: Insecure Window Configuration for PDF Export (Medium)
CVSS 3.1 Score: 6.5 (Medium) CWE-1021: Improper Restriction of Renderers
Location: src/main.js (lines 2579-2585)
const pdfWindow = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
Description: Hidden windows created for PDF export also have insecure configurations, allowing potential privilege escalation.
Remediation:
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
sandbox: true
}
CVE-MC-007: PlantUML Server Data Exfiltration (Medium)
CVSS 3.1 Score: 5.3 (Medium) CWE-359: Exposure of Private Information
Location: src/renderer.js (lines 470-487)
const plantumlBlocks = preview.querySelectorAll('pre code.language-plantuml');
plantumlBlocks.forEach((block) => {
const code = block.textContent;
// ...
const encoded = plantumlEncode(code);
const img = document.createElement('img');
img.src = `https://www.plantuml.com/plantuml/svg/${encoded}`;
// ...
});
Description: PlantUML diagram content is sent to an external server (plantuml.com) for rendering. This could leak sensitive information contained in diagrams.
Exploitability:
- Diagrams containing proprietary information, system architecture, or internal processes are sent to third-party servers
- No user consent or notification before external data transmission
Remediation:
- Use local PlantUML rendering with Java
- Add user warning before sending data to external service
- Implement opt-in for external rendering
CVE-MC-008: Inconsistent Security Settings Across Windows (Medium)
CVSS 3.1 Score: 5.5 (Medium) CWE-1021: Improper Restriction of Renderers
Description: Security settings are inconsistent across different windows:
| Window | nodeIntegration | contextIsolation | Security |
|---|---|---|---|
| Main Window | true | false | Insecure |
| About Dialog | false | true | Secure |
| Dependencies Dialog | false | true | Secure |
| ASCII Generator | false | true | Secure |
| Table Generator | false | true | Secure |
| PDF Export Window | true | false | Insecure |
| Hidden Conversion Window | true | false | Insecure |
Remediation:
Apply secure configuration (nodeIntegration: false, contextIsolation: true) consistently across all windows.
CVE-MC-009: Command Execution via External Tools (Low)
CVSS 3.1 Score: 4.4 (Low) CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Location: src/main.js (lines 1915-1972)
Description:
While the application uses execFile instead of exec (good practice), external tools (Pandoc, LibreOffice, FFmpeg, ImageMagick) are invoked with file paths that could potentially be manipulated.
Positive Finding:
The code correctly uses execFile with argument arrays instead of shell commands, mitigating most command injection vectors.
Remaining Risk:
- File paths are not validated against malicious names
- Special characters in filenames could cause issues with external tools
Remediation:
- Validate file paths before passing to external tools
- Sanitize filenames of special characters
CVE-MC-010: Missing Dependency Version Pinning (Low)
CVSS 3.1 Score: 3.5 (Low) CWE-1035: Using Components with Known Vulnerabilities
Location: package.json
Description:
Dependencies use ^ version ranges which could allow automatic updates to versions with vulnerabilities:
"dependencies": {
"marked": "^17.0.3",
"dompurify": "^3.3.1",
"mermaid": "^11.12.3",
// ...
}
Remediation:
- Pin exact versions in production
- Use lockfile (package-lock.json)
- Implement dependency scanning in CI/CD pipeline
Attack Surface Map
┌─────────────────────────────────────────────────────────────────┐
│ EXTERNAL ATTACK SURFACE │
├─────────────────────────────────────────────────────────────────┤
│ Markdown Files (.md) ─────► XSS via Preview Rendering │
│ Code Blocks ─────► Arbitrary Code Execution │
│ PlantUML Diagrams ─────► Data Exfiltration │
│ External CDNs ─────► Supply Chain Attacks │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ RENDERER PROCESS (Insecure) │
├─────────────────────────────────────────────────────────────────┤
│ nodeIntegration: true ─────► Direct Node.js Access │
│ contextIsolation: false ─────► Prototype Pollution Risk │
│ DOMPurify Sanitization ─────► May be bypassed via extensions │
│ Custom Marked Extensions ────► XSS Vectors │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ IPC BRIDGE (Preload.js) │
├─────────────────────────────────────────────────────────────────┤
│ Channel Whitelisting ─────► Good Practice │
│ Not Used for Main Window ────► Security Bypassed │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ MAIN PROCESS (Full Privileges) │
├─────────────────────────────────────────────────────────────────┤
│ File Operations ─────► No Path Validation │
│ Code Execution ─────► Python/Bash via REPL │
│ External Tools ─────► Pandoc, FFmpeg, LibreOffice │
│ PDF Operations ─────► Merge, Encrypt, Decrypt │
└─────────────────────────────────────────────────────────────────┘
Positive Security Findings
- Preload.js Implementation: A secure IPC bridge with channel whitelisting is implemented
- DOMPurify Usage: HTML sanitization is applied to markdown output
- execFile Usage: External commands use
execFileinstead ofexec - File Size Limits: 50MB maximum file size is enforced
- Rate Limiting: Conversion operations have rate limiting (2 second minimum interval)
- Error Message Sanitization: Absolute paths are stripped from error messages
Prioritized Remediation Roadmap
Phase 1 - Critical (Immediate)
- Set
nodeIntegration: falseandcontextIsolation: truefor main window - Remove or sandbox the code execution (REPL) feature
- Implement proper preload.js usage for all windows
Phase 2 - High Priority (1-2 Weeks)
- Add path traversal protection to file operations
- Strengthen Content Security Policy
- Audit and fix custom markdown extensions for XSS
Phase 3 - Medium Priority (1 Month)
- Implement consistent security settings across all windows
- Add local PlantUML rendering option
- Implement dependency scanning in CI/CD
Phase 4 - Low Priority (Ongoing)
- Pin dependency versions
- Add security headers to all generated HTML
- Implement security logging and monitoring
Compliance Considerations
- OWASP Top 10 2021: A03:2021 - Injection, A05:2021 - Security Misconfiguration
- OWASP ASVS: V12 - File Handling, V13 - API Security
- NIST CSF: PR.AC - Access Control, PR.DS - Data Security
Conclusion
The MarkdownConverter application has significant security vulnerabilities that could allow an attacker to execute arbitrary code, access sensitive files, and compromise the user's system. The most critical issue is the insecure Electron configuration combined with XSS attack vectors in the markdown rendering pipeline.
Overall Security Rating: HIGH RISK
The positive finding is that much of the security infrastructure (preload.js, DOMPurify) is already in place but not properly utilized. With focused remediation effort, the application can achieve a much stronger security posture.