Skip to content

[Medium] Automation re-export doesn't verify the target stays inside the automations root #17

Open

Description

@adilei

Severity

Medium — missing path-containment check on a write path (defense-in-depth gap; the skill builder has the guard, this one doesn't).

Location

electron/automationbuilder/builder.ts:224:

let dir = prior?.exportedPath ? path.dirname(prior.exportedPath) : path.join(root, name);

Compare with the skill builder, which validates containment via an isInside(...) check (electron/skillbuilder/builder.ts:282).

Mechanism

On re-export, the target directory is derived from path.dirname(prior.exportedPath), where prior comes from previously persisted automation data. That value is used to mkdirSync + writeFileSync(automation.json) without verifying it still resolves inside automationsRoot(). A tampered/relocated exportedPath writes outside the intended root.

Impact

automation.json can be written outside the automations root (arbitrary-ish write within the user's permissions).

Suggested fix

Before writing, assert the resolved dir is inside automationsRoot() (reuse the skill builder's isInside containment check); otherwise fall back to a fresh in-root directory.

Regression test to add (npm test)

Unit test: seed a persisted automation whose exportedPath points outside root (e.g. via ..), call the export, and assert it refuses / rewrites inside root. Deterministic; not an evals/ concern.

Activity

  1. added a commit that references this issue on Aug 7, 2026
    6fe4469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions