aaronsb_obsidian-mcp-plugin/github-issues/01-authentication-vulnerability.md
Aaron Bockelie 36301118a9 docs: Add comprehensive project documentation and security audit
- Add CONTRIBUTING.md with development guidelines
- Add SECURITY.md with vulnerability reporting policy
- Create GitHub issue templates for bugs and features
- Add PR template with checklist
- Set up GitHub Actions for testing and security scanning
- Document all security findings from code audit
- Create detailed GitHub issues for all vulnerabilities
- Update CHANGELOG with security audit results
- Add project structure documentation

This establishes proper open-source project structure and documents
all critical security issues that need to be addressed.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-12 00:14:45 -05:00

2.7 KiB

🔴 CRITICAL: No Authentication or Authorization on MCP Server

Summary

The MCP server exposes full vault access over HTTP without any authentication mechanism, allowing any local application to read, write, and delete files in the Obsidian vault.

Current Behavior

  • Server runs on http://localhost:3001 with no API key validation
  • CORS configured to allow ALL origins (origin: '*')
  • No user authentication or role-based access control
  • Any local process can manipulate the entire vault

Security Impact

  • Severity: CRITICAL
  • Attack Vector: Local network access
  • Impact: Complete vault compromise, data loss, unauthorized access

Vulnerable Code

// mcp-server.ts:248-253
this.app.use(cors({
  origin: '*',  // Allows any origin!
  methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
  allowedHeaders: ['Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'Authorization', 'Mcp-Session-Id'],
  exposedHeaders: ['Mcp-Session-Id']
}));

Reproduction Steps

  1. Install and enable the plugin
  2. From any local application, run:
    curl -X POST http://localhost:3001/mcp \
      -H "Content-Type: application/json" \
      -d '{"method": "tools/vault", "params": {"action": "list"}}'
    
  3. Observe full vault file listing returned without authentication

Proposed Solution

Phase 1: Basic API Key Authentication

interface AuthConfig {
  apiKey: string;
  allowedOrigins: string[];
  requireHttps: boolean;
}

class AuthMiddleware {
  private config: AuthConfig;
  
  authenticate(req: Request, res: Response, next: NextFunction) {
    const apiKey = req.headers['x-api-key'];
    
    if (!apiKey || apiKey !== this.config.apiKey) {
      return res.status(401).json({ error: 'Unauthorized' });
    }
    
    next();
  }
}

Phase 2: Token-Based Authentication

  • Generate secure session tokens
  • Implement token refresh mechanism
  • Add rate limiting per token

Phase 3: Role-Based Access Control

  • Read-only vs read-write permissions
  • Path-based restrictions
  • Operation whitelisting

Mitigation Steps (Immediate)

  1. Restrict CORS to specific origins
  2. Add API key requirement
  3. Implement rate limiting
  4. Add authentication logging

References

Acceptance Criteria

  • API key authentication implemented
  • CORS restricted to configurable origins
  • Authentication failures logged
  • Settings UI for managing API keys
  • Documentation updated with security setup

Labels

security critical authentication breaking-change