Skip to content

fix(security): validate AST link schemes, guard local POST CSRF, fix volume & DOM leaks #81

Done

Description

@mlgitdev

Description

Security, efficiency, and cleanup defects verified across backend and UI:

  1. Unvalidated href scheme: ast_to_html() (app/news.py:189-192) emits <a href="{url}"> without checking http:// or https://, allowing javascript: URIs in story HTML rendered via innerHTML.
  2. Local HTTP CSRF surface: Mutating POST routes in app/server.py (such as /api/clear_tape, /api/pop_tape, /api/refresh) lack Origin/Referer localhost checks, allowing cross-site simple POST requests from external web pages.
  3. Redundant volume writes: setVolume(vol, true) (web/js/app.js:187-190) fires both POST /api/set_volume and POST /api/config back-to-back.
  4. DOM/listener leaks: U.pop() (web/js/util.js:234-239) leaks document mousedown listeners when closed via U.closePops(), and Settings.readJsonFile() (web/js/settings.js:876-906) leaks hidden <input type="file"> elements on dialog cancel.

References: app/news.py:189-192, app/server.py:267-290, web/js/app.js:187-190, web/js/util.js:222-241, web/js/settings.js:876-906

Steps to Reproduce

  1. Pass {"type": "url", "params": {"url": "javascript:alert(1)"}} to ast_to_html() -> outputs <a href="javascript:alert(1)">.
  2. Click #vol-bar-track in the UI and inspect Network -> fires both POST /api/set_volume and POST /api/config.
  3. Open a popover and call U.closePops(), or open file import and cancel -> listener / hidden <input> persists.

Expected Behavior

Allow only http:// and https:// URLs in ast_to_html(), reject non-localhost Origin headers on mutating /api/* POST routes, stop calling redundant App.saveConfig(true) in setVolume(), track/remove U.pop() listeners in U.closePops(), and clean up file inputs on cancel.

Operating System & Version

  • OS: Windows 11 x64 / macOS arm64 / Linux x86_64
  • Version: v2.12.0
  • Display / Scale: Verified via live Chrome CDP (1600x960) & local unit/backend suite

Logs & Additional Context

Live Chrome CDP verified duplicate POST /api/set_volume + POST /api/config; backend test verified <a href="javascript:alert(1)" data-ext="1">Click</a>.

Activity

  1. added
    bug
    on Dec 2, 2026
  2. self-assigned this
    on Dec 2, 2026
  3. github-actions commented on Dec 2, 2026

    @github-actions

    ✅ Issue Validation Passed

    • Conventional Commit title syntax (fix(security))
    • Verified issue type: BUG
    • Required template sections present and filled out

    This issue is well-structured and ready for work according to the Issue-First Protocol.

  4. mlgitdev commented on Dec 2, 2026

    @mlgitdev
    OwnerAuthor

    🚀 Resolution In Progress

    A fix for this issue has been implemented and submitted in Pull Request #82 (v2.12.1).

    • Branch: fix/audit-remediation-67
    • PR URL: fix(core): resolve 15 verified audit issues across UI, API, concurrency, audio, and packaging (v2.12.1) #82
    • Summary of Changes: Restricted ast_to_html() links and open_url() to http:///https://, added localhost Origin/Referer CSRF protection on mutating /api/* POST routes (app/server.py), removed duplicate POST /api/config on volume drag (web/js/app.js), and cleaned up U.pop() listeners & cancelled file inputs. Verified via unit tests and live Chrome CDP.
    • Verification: compileall clean, 84/84 unit tests passing (including tests/test_audit_fixes.py), and live Chrome CDP verification passed.

    This issue will automatically close upon PR #82 review and merge into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions