Skip to content

Malformed-but-valid JSON escapes loader error handling in project files and component-library discovery #48

Description

@striderZA

Summary

loadProject() and ComponentLibrary::loadFile() catch parse errors but then perform unchecked typed access on well-formed JSON with wrong types (e.g. root["components"], cj["params"], j["type"].get<std::string>()), which can throw nlohmann::json exceptions outside the handled boundary.

Severity: Important (robustness / DoS)

Evidence

  • app/src/app.cpp loadProject() catches JSON parse errors only around in >> root, then does unchecked structured access.
  • app/src/component_library.cpp loadFile() catches only nlohmann::json::parse_error, then uses typed reads (j["type"].get<std::string>(), df["path"].get<std::string>()) without validating field types.
  • ComponentLibrary::scan() / refreshExtensions() don't wrap the later type conversions, so exceptions can escape the discovery boundary.
  • tests/test_project_file.cpp covers only syntactically invalid JSON, not wrong-type payloads.

Impact

A crafted .rfsim or component JSON with unexpected types can abort load/refresh unexpectedly and may terminate the app if the exception propagates out of the UI frame. Practical DoS path for untrusted project/library content.

Suggested fix

Validate schema/types before field extraction, catch nlohmann::json::exception around the full load path (not just parse), and add negative tests for wrong-type project and component payloads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity, trust-boundary, or supply-chain issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions