Skip to content

v2.2.0

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Nov 18:22
Immutable release. Only release title and notes can be modified.
e00ead1

Security

  • kses() now filters executable markup with its default config. Previously the default $config = 1 ran htmLawed with no filtering, so <script>, on* event handlers and javascript: URLs survived and {!! kses( $html ) !!} was open to stored XSS. The default is now Security::KSES_SAFE_CONFIG (htmLawed safe mode, no <style>, <link> or <meta> elements, no on* or style attributes); javascript: and data: URLs are rewritten to denied:…. Behavior change: callers that relied on the permissive default must now pass their own $config. sanitize() / BaseFormRequest with the html rule and the opt-in XssProtection middleware pick up the same default. Passing any config other than 1 is forwarded unchanged (#52, #53).
  • The default kses() config also removes elements that can restyle or hijack the page: <base>, <form> and form controls (<input>, <button>, <select>, <option>, <optgroup>, <textarea>, <datalist>, <keygen>, <isindex>) and frames (<frame>, <frameset>), which allowed fake login forms on the site's own origin. URLs are limited to http/https, plus mailto and tel for href; any other scheme (ftp:, file:, …) is rewritten to denied:…. Relative and fragment URLs are kept. Custom (hyphenated) elements are now dropped (their text is kept) and the ping attribute is denied: htmLawed let custom elements keep every attribute, so Alpine/Livewire directives such as <x-a x-data x-init="…"> survived kses() and ran as script. Custom element names returned by ap.security.ksesAllowedTags are ignored for the same reason. The default also removes class attributes (so content can't borrow the site's CSS classes for a full-page phishing overlay) and Alpine/Livewire directive attributes (x-*, @*, :*, wire:*) and is on every element, even when $spec permits them. It drops rel="opener" and adds noopener to links with a target (reverse tabnabbing), and prefixes id/name values with user-content- (DOM clobbering). #fragment links and ID references (usemap, headers, for, aria-labelledby, …) are rewritten to match, and sanitizing already-prefixed output again leaves it unchanged. New public Security::KSES_ID_PREFIX and Security::ksesSafeTag() (the hook_tag in KSES_SAFE_CONFIG). Behavior change: content that relied on forms or other URL schemes passing through kses() must pass its own $config (#50).
  • Under the default config, IDs stay unique after the user-content- prefix is added: a repeated id or one containing whitespace is dropped. Uniqueness is checked per kses() call (htmLawed's unique_ids is off in KSES_SAFE_CONFIG), so sanitizing content again, or sanitizing two fragments that share an ID, no longer strips IDs. Before this, htmLawed remembered IDs across calls, so a third pass or a second call dropped the id and broke #fragment links. itemref values are now prefixed too.
  • Under the default config, $spec can no longer re-enable on*, style, class or ping attributes (htmLawed lets $spec override deny_attribute). Those entries are dropped before the spec reaches htmLawed (#52).
  • Tags returned by the ap.security.ksesAllowedTags filter can no longer re-enable script, style, link, meta, base, iframe, frame, frameset, object, embed, applet, audio, video, canvas, dialog, or forms and form controls. Entries are trimmed and lowercased, and anything that isn't a plain element name (wildcards, htmLawed +/- operators, comma lists, non-strings) is ignored. The safe attribute and URL rules also apply to the filtered list (#50, #52).

Added

  • The release workflow now has a sync-docs job that queues documentation and changelog imports on docs.artisanpackui.dev after each release. It needs the DOCS_API_TOKEN org secret and skips with a notice when the secret isn't set. Both imports are attempted on every run, and the job fails unless each returns 202. Set a DOCS_PACKAGE_SLUG repository variable if the docs-site slug ever differs from the repo name. The Packagist update now runs in its own job, so a Packagist failure no longer blocks the docs import, and the workflow defaults to read-only GITHUB_TOKEN permissions (#51).
  • New HTML filtering guide covering the safe kses() default, narrowing elements with ap.security.ksesAllowedTags, $spec and custom configs, plus an "Upgrading to 2.2" section in UPGRADE.md. The API reference now documents Security::KSES_SAFE_CONFIG, Security::KSES_ID_PREFIX and Security::ksesSafeTag().

Changed

  • The XssProtection middleware no longer filters the input keys listed in the new artisanpack.security.xss.except config (password, password_confirmation and current_password by default), at any nesting depth. With the stricter kses() default, filtering passwords could stop existing credentials from matching their hashes.
  • The release workflow's docs import requests now time out after 30 seconds, so a stalled import-docs call can't stop import-changelog from running.
  • The security report generator's generatorVersion metadata now reports 2.2.0.
  • The global kses() helper now accepts and forwards $config and $spec like Security::kses(). Previously it silently dropped them (#52).

Fixed

  • Bundled htmLawed: safe mode no longer throws on style attributes containing url(…) (the hl_url callback didn't resolve in the namespaced copy). Corrupted srcset/archive/itemtype and abs_url code paths are repaired, and $spec strings now parse on every call instead of failing on the namespaced hl_aux1/hl_aux2 callbacks. srcset values are no longer run through hl_url() a second time (which double-converted the first candidate under abs_url). A $spec default now goes through the same checks as an input value (values the spec only filtered aren't re-checked): each srcset candidate gets the scheme check, and a style default gets the CSS url() and expression checks. srcset values are split into candidates per the HTML parsing rules, so commas inside a URL (such as a data: URL) no longer split it. A style attribute generated from deprecated markup (<center>, <font>, align, bgcolor, …) is dropped when deny_attribute or a $spec -style rule denies style. An integer unique_ids config value no longer throws a TypeError (#52, #53).