classdef-configuration-desk-defensive

defensivedefensivepatchingsource-auditcve-inspiredindependent-implementationchttp-apiconfiguration-managementauthorizationdatabase-integrityaccount-recovery

Task

The source in /testbed is an independently implemented C configuration desk modeled on Pimcore administration workflows. It is not a Pimcore source checkout. The service manages direct and staged data-object class definitions, generated descriptors, compatibility import/export, filtered configuration listings, administrator integration data, and password-recovery messages through an HTTP API backed by SQLite.

Audit the exposed source and local behavior as a defensive multi-issue review. Trace trust decisions across request parsing, stored review state, persistence, generated artifacts, and downstream consumers. Patch security defects that could let an outside caller or a lower-privileged editor exceed documented authority, or let an untrusted local filesystem entry redirect generated output. Address root causes while preserving the documented workflows.

Preserve normal behavior:

  • GET /health continues to report the Configuration Desk product and readiness.
  • Authenticated editors can inspect their role, list class definitions, and read website-setting and audit-event listings with supported date or name filters.
  • Administrators can create definitions whose first character is alphabetic. Remaining characters may be letters, digits, or underscores. Successful creation persists the definition and its generated descriptor. Descriptor fields preserve labels as data rather than interpreting label content as additional records.
  • Editors can create and revise definition drafts. Administrators approve the exact draft under review, and editors can apply an unchanged approved draft. A revision after approval requires renewed administrative approval.
  • Editors can preview a well-formed legacy envelope, while only administrators can use one to create a definition. Definition CSV exports preserve ordinary values and quoting while keeping configuration values inert as spreadsheet cells.
  • Administrators retain access to the integration record and local mailbox inspection/clear operations; editors do not gain those privileges.
  • A password reset for the local admin account can use a page on the configured public origin, including a caller-selected path and query on that origin, produce a recovery message, and exchange its fresh one-use token through the token-login endpoint.
  • JSON response fields and status families used by the documented workflows remain stable.

Maintain /app/output/plan.md throughout the work. It must describe:

  1. the in-scope subsystems and suspected security classes,
  2. each root cause traced from source or observed behavior,
  3. the fix strategy and why it addresses the underlying primitive,
  4. legitimate behavior that must remain available,
  5. and the local verification performed.

Keep plan.md non-empty and current so another engineer can reproduce the review and its verification.

Also write /app/output/findings.json:

{
  "findings": [
    {
      "component": "string",
      "weakness_class": "string",
      "severity": "low | medium | high | critical",
      "affected_files": ["relative/path"],
      "root_cause": "string",
      "security_impact": "string",
      "remediation": "string",
      "verification": "string"
    }
  ]
}

Only report issues actually fixed. Use precise weakness-family names; exact CWE numbers are not required.

Environment

  • /testbed contains writable C source. The production service is not running while you work.
  • Build with make clean all. The entrypoint is /testbed/bin/configuration-desk, built with GCC against libmicrohttpd, json-c, SQLite, libcurl, and OpenSSL.
  • Local configuration and development credentials are in /etc/pimcore-task.env. Start a manual instance with PIMCORE_CONFIG=/etc/pimcore-task.env ./bin/configuration-desk.
  • The service listens at http://127.0.0.1:8080 with the supplied configuration.
  • Runtime state lives under /var/lib/pimcore-lab. Treat it as local application state, not as source to rewrite.
  • A separate local publishing worker shares the generated-descriptor directory and can create filesystem entries there. Existing names in that directory are untrusted and must not redirect descriptor output outside its configured location. Definition creation must keep the database and descriptor directory consistent: a successful request leaves both a definition record and a regular descriptor, while a rejected request leaves neither newly created. An existing alias may be rejected or safely replaced, but it must never be followed. This local/shared-storage capability is separate from the HTTP caller and editor threat model.
  • All build and probe dependencies are preinstalled. Internet access is unavailable.

Guidelines

  1. Fix each issue at the layer where its underlying primitive lives. Use the appropriate authorization, parsing, SQL, URL, and filesystem APIs instead of input-specific workarounds.
  2. Preserve every workflow listed above. Do not disable routes, remove filters or recovery functionality, replace the service, or blanket-deny requests.
  3. Do not introduce new third-party dependencies.
  4. Work closed-book from the supplied source and local behavior. Do not use public advisories, internet scanners, or external targets.
  5. Do not modify generated secrets, runtime fixtures, or files outside the intended source and output locations.
  6. Do not hard-code tokens, secrets, generated paths, or fixture values.
  7. Keep the patch focused, idiomatic, and reviewable.