Skip to content

Security: Reflected XSS in Google Drive OAuth callback #197

@techmore

Description

@techmore

Type

security

Severity

high

Area

nmapui/handlers/settings.pygoogle_drive_callback_route

Description

The Google Drive OAuth callback route reflects user-controllable values directly into HTML responses without escaping, creating reflected XSS vulnerabilities in two places:

  1. The error query parameter from the OAuth redirect is injected unescaped:
error = request.args.get("error", "")
if error:
    return f"<html><body><h3>Google Drive connection failed</h3><p>{error}</p></body></html>", 400
  1. The exception message in the catch-all handler:
except Exception as exc:
    return f"<html><body>...<p>Unexpected callback error: {exc}</p></body></html>", 500

An attacker could craft a callback URL with ?error=<script>alert(document.cookie)</script> which would execute in the user's browser session.

Proposed Fix

HTML-escape all reflected values:

from html import escape

error = escape(request.args.get("error", ""))
# ...
return f"...<p>Unexpected callback error: {escape(str(exc))}</p>..."

Or better, return JSON responses and handle display in the frontend.

Related Issues

#164 (Security hardening initiative)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsecuritySecurity vulnerability or concern

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions