Skip to content

Security Scan Report - Hackathon TV5 Project #6

@proffesor-for-testing

Description

@proffesor-for-testing

Security Scan Report - Hackathon TV5 Project

Scan Date: 2025-12-03
Project: hackathon-tv5
Scanner: QE Security Scanner Agent v1.0.0
Overall Risk: 🔴 HIGH


Executive Summary

Comprehensive security analysis identified 8 vulnerabilities across the hackathon-tv5 CLI and MCP server implementation. Two CRITICAL vulnerabilities require immediate remediation:

  • Dependencies: Clean (0 known vulnerabilities)
  • ⚠️ OWASP Compliance: 54% (FAILING - 6/10 categories)
  • 🔴 Critical Issues: 2 (Command Injection, Path Traversal)
  • 🟠 High Issues: 3 (CORS, Rate Limiting, Logging)

Critical Vulnerabilities (Immediate Action Required)

🔴 VULN-001: Command Injection via Tool Installation

CVSS 9.8 | CRITICAL

Location: src/utils/installer.ts:73-105

Problem:
The runCommand() function executes commands with shell: true, allowing arbitrary command injection through tool installation parameters.

Attack Vector:

// Malicious tool definition
installCommand: 'npm install package; rm -rf /'

Fix:

// SECURE VERSION - Remove shell execution
import { execa } from 'execa';

const ALLOWED_COMMANDS = ['npm', 'npx', 'pip', 'python'];

export async function runCommand(command: string): Promise<string> {
  const parts = command.split(' ');
  const cmd = parts[0];

  if (!ALLOWED_COMMANDS.includes(cmd)) {
    throw new Error(`Command '${cmd}' not allowed`);
  }

  const result = await execa(cmd, parts.slice(1));
  return result.stdout;
}

🔴 VULN-002: Path Traversal in Configuration Files

CVSS 9.1 | CRITICAL

Location: src/utils/config.ts:35-59

Problem:
No validation on directory paths allows reading/writing arbitrary files via path traversal (../../../etc).

Attack Vector:

loadConfig('../../../../etc/passwd')
saveConfig(maliciousData, '../../../root/.bashrc')

Fix:

// SECURE VERSION
import { resolve, normalize } from 'path';

const ALLOWED_BASE_DIR = process.cwd();

export function getConfigPath(dir: string = process.cwd()): string {
  const absoluteDir = resolve(dir);

  if (!absoluteDir.startsWith(ALLOWED_BASE_DIR)) {
    throw new Error('Access denied: Path outside project directory');
  }

  if (dir.includes('..')) {
    throw new Error('Path traversal detected');
  }

  return join(absoluteDir, CONFIG_FILE);
}

High Priority Vulnerabilities

🟠 VULN-003: Overly Permissive CORS Configuration

CVSS 7.5 | HIGH

Location: src/mcp/sse.ts:20-29

Problem:
CORS set to Access-Control-Allow-Origin: * allows any website to interact with the MCP server.

Impact: Malicious websites can trigger MCP actions while server runs locally.

Fix:

const ALLOWED_ORIGINS = ['http://localhost:3000'];

app.use((req, res, next) => {
  const origin = req.headers.origin;
  if (origin && ALLOWED_ORIGINS.includes(origin)) {
    res.setHeader('Access-Control-Allow-Origin', origin);
  }
  next();
});

🟠 VULN-004: Missing Rate Limiting

CVSS 7.5 | HIGH

Location: src/mcp/sse.ts:14-73

Problem:
No rate limiting, connection limits, or request size restrictions enable DoS attacks.

Fix:

import rateLimit from 'express-rate-limit';

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100,
  message: 'Too many requests'
});

app.use(express.json({ limit: '1mb' }));
app.use('/rpc', limiter);

🟠 VULN-005: Insufficient Security Logging

CVSS 7.2 | HIGH

Location: Multiple files

Problem:
No audit trail for security events (command execution, file operations, MCP requests). Errors expose internal details.

Fix:

import winston from 'winston';

const securityLogger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  transports: [
    new winston.transports.File({ filename: 'security-audit.log' })
  ]
});

// Log all security-relevant events
securityLogger.info('command_execution', {
  command: sanitizedCommand,
  user: process.env.USER,
  timestamp: new Date().toISOString()
});

Medium Priority Vulnerabilities

🟡 VULN-006: Information Disclosure

CVSS 5.3 | MEDIUM

Location: src/mcp/sse.ts:32-91

Endpoints expose server version, capabilities, and internal structure without authentication.

Fix: Remove version info, require authentication for /health and / endpoints.


🟡 VULN-007: Unsafe JSON Parsing

CVSS 4.3 | MEDIUM

Location: src/mcp/stdio.ts:25, src/utils/config.ts:51

JSON parsing without validation enables prototype pollution and DoS.

Fix: Use ajv for schema validation, secure-json-parse for safe parsing.


Low Priority Vulnerabilities

🟢 VULN-008: Missing Security Headers

CVSS 3.7 | LOW

Location: src/mcp/sse.ts:13-17

No security headers (CSP, X-Frame-Options, etc.) configured.

Fix:

import helmet from 'helmet';
app.use(helmet());

Dependency Analysis

✅ NPM Audit: CLEAN

  • Total Dependencies: 268 (129 prod, 140 dev)
  • Known Vulnerabilities: 0
  • Outdated Packages: Express 4.18.2 → 4.19.2 (update recommended)

OWASP Top 10 Compliance

Category Status Score Issues
A01: Broken Access Control 🔴 FAILING 40% Path Traversal, CORS
A02: Cryptographic Failures ✅ PASSING 100% None
A03: Injection 🔴 FAILING 0% Command Injection
A04: Insecure Design 🔴 FAILING 30% No Rate Limiting
A05: Security Misconfiguration 🔴 FAILING 40% CORS, Headers
A06: Vulnerable Components ✅ PASSING 100% None
A07: Auth Failures 🔴 FAILING 50% No MCP Auth
A08: Data Integrity 🔴 FAILING 60% JSON Parsing
A09: Logging Failures 🔴 FAILING 20% No Security Logs
A10: SSRF ✅ N/A 100% Not Applicable

Overall Compliance Score: 54%


Remediation Priority

🚨 Immediate (This Week)

  1. ✅ Fix command injection (VULN-001)
  2. ✅ Fix path traversal (VULN-002)
  3. ✅ Implement input validation across all user inputs
  4. ✅ Add authentication to MCP endpoints

📅 Short-term (This Month)

  1. Fix CORS configuration (VULN-003)
  2. Add rate limiting (VULN-004)
  3. Implement security logging (VULN-005)
  4. Add request validation schemas
  5. Update dependencies (Express)

🎯 Long-term (This Quarter)

  1. Conduct penetration testing
  2. Implement automated security scanning in CI/CD
  3. Add security training for developers
  4. Create incident response plan
  5. Regular security audits

Testing Recommendations

SAST (Static Analysis)

  • Semgrep: Pattern-based vulnerability detection
  • SonarQube: Comprehensive code quality
  • ESLint Security Plugins: JavaScript-specific issues

DAST (Dynamic Analysis)

  • OWASP ZAP: Automated web app scanning
  • Burp Suite: Manual penetration testing
  • Postman: API security testing

Dependency Scanning

  • npm audit: Built-in vulnerability scanner
  • Snyk: Continuous monitoring + auto-PRs
  • Dependabot: GitHub-integrated updates

Code Examples for Quick Fixes

1. Secure Command Execution

// Install: npm install execa
import { execa } from 'execa';

const ALLOWED = ['npm', 'npx', 'pip', 'python'];

async function runCommand(cmd: string): Promise<string> {
  const [command, ...args] = cmd.split(' ');
  if (!ALLOWED.includes(command)) {
    throw new Error('Command not allowed');
  }
  const { stdout } = await execa(command, args);
  return stdout;
}

2. Path Validation

import { resolve } from 'path';

function validatePath(inputPath: string): string {
  const basePath = process.cwd();
  const fullPath = resolve(basePath, inputPath);

  if (!fullPath.startsWith(basePath) || inputPath.includes('..')) {
    throw new Error('Invalid path');
  }
  return fullPath;
}

3. Rate Limiting

import rateLimit from 'express-rate-limit';

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 min
  max: 100 // requests per window
});

app.use('/rpc', limiter);

4. Security Headers

import helmet from 'helmet';

app.use(helmet({
  contentSecurityPolicy: true,
  frameguard: { action: 'deny' },
  hsts: { maxAge: 31536000 }
}));

Resources


Contact

For questions about this security scan:

  • Scanner: Agentic QE Security Scanner Agent
  • Report Location: /docs/security-scan-report-2025-12-03.json
  • Date Generated: 2025-12-03

Next Steps: Review the detailed JSON report and prioritize fixes based on CVSS scores and exploitability.

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