Skip to content

Metadata export: ValueError message returned to anonymous users (CodeQL information exposure) #240

Open

Description

@saqibmanan

What: In api/views/metadata_export.py:49, except ValueError as exc wraps the whole export_dataset() call and returns str(exc) with a 400. CodeQL flags this as information exposure through an exception (raised on #239).
Why it matters: The endpoint is public. Any internal ValueError (from the crosswalk, date handling or rdflib) reaches an anonymous user verbatim and is reported as a client error instead of a 500.
Evidence: Only the 2 ValueErrors at exporter.py:106-113 (unknown standard / format) are meant for users.
Fix: Not fixed yet. Validate standard/fmt against crosswalk.standard_ids() / allowed_formats() before the try, and return a fixed message plus export_options(). Let every other exception fall through to the existing generic 500 handler. test_api_018's 400 test still passes.

Activity

  1. added theissue type on Oct 9, 2026
  2. added a commit that references this issue on Oct 12, 2026
    b66f511
  3. anantjain341 commented on Oct 12, 2026

    @anantjain341
    Contributor

    Fix: Merged into dev in #245. The view now checks standard and format against export_options() before exporting and returns a fixed 400 message with the options. The except ValueError that returned str(exc) is removed, so every other error falls to the logged generic 500. No migration.
    Check after deploy: GET /api/datasets/<uuid>/export/?standard=xyz should return {"error": "Unknown standard", "options": …} with 400, without the input echoed back.

    Moving to Ready to test.

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions