Skip to content

views: escaping misses single quotes and view paths are not confined #28

Closed

Description

@schlessera

Context

SimpleView::escape() uses htmlspecialchars( $value, ENT_COMPAT, 'UTF-8' ) (src/Infrastructure/View/SimpleView.php:282). ENT_COMPAT leaves single quotes unescaped, so an escaped value inside a single-quoted HTML attribute can break out of it.

View paths are not confined to an allowed root. SimpleView::validate() prefixes the plugin root and accepts .. segments (:179-186); TemplatedView::validate() falls back to any readable path it was given (src/Infrastructure/View/TemplatedView.php:70-84). Both then include the file (SimpleView.php:96-117). If a view name is ever derived from input, that is an arbitrary local-file include. The samples only use literal names, so this is hardening, not a live exploit.

Scope

  • Escape with ENT_QUOTES (and keep substituting invalid code units).
  • Resolve view paths to their canonical form and reject any path that leaves the allowed locations (the plugin root, plus the theme override locations) with InvalidPath.

Out of scope

  • Context-specific escaping helpers (attribute, URL, JavaScript); principle 9 expects templates to use WordPress's esc_* functions for those.
  • Scoping theme overrides per plugin (tracked separately).

Acceptance criteria

  • A value containing ' is escaped; a test fails before the change and passes after.
  • A view name containing .. that resolves outside the allowed locations throws InvalidPath; tests for SimpleView and TemplatedView.
  • Existing view tests still pass.

Verification

composer test
composer lint

Impact on generated plugins

No: this does not change an interface or convention generated plugins rely on.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: infrastructuresrc/Infrastructure: services, injector, views, autoloader. What generated plugins build on.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    securityEscaping, sanitization, capabilities, nonces, or anything exploitable.
    on Oct 22, 2026
  2. self-assigned this
    on Oct 23, 2026
  3. schlessera commented on Oct 23, 2026

    @schlessera
    MemberAuthor

    Picking this up on branch fix/28-view-escaping-and-path-confinement. The citations in the body still match origin/main (5ab9ad1).

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: infrastructuresrc/Infrastructure: services, injector, views, autoloader. What generated plugins build on.priority: p1Next up.securityEscaping, sanitization, capabilities, nonces, or anything exploitable.type: fixSomething is broken and must behave the way it is documented.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions