You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+9
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,15 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
6
6
7
7
## [Unreleased][unreleased]
8
8
9
+
This is a **security release** to address a potential cross-site scripting (XSS) vulnerability when using the `AttributesExtension` with untrusted user input.
10
+
11
+
### Added
12
+
- Added `attributes/allow` config option to specify which attributes users are allowed to set on elements (default allows virtually all attributes)
13
+
14
+
### Changed
15
+
- The `AttributesExtension` blocks all attributes starting with `on` unless explicitly allowed via the `attributes/allow` config option
16
+
- The `allow_unsafe_links` option is now respected by the `AttributesExtension` when users specify `href` and `src` attributes
The `AttributesExtension` allows HTML attributes to be added from within the document.
11
11
12
+
**Security warning:** Allowing untrusted users to inject arbitrary HTML attributes could lead to XSS vulnerabilities, styling issues, or other problems. Consider [disabling unsafe links](/2.7/security/#unsafe-links), [configuring allowed attributes](#configuration), and/or [using additional filtering](/2.7/security/#additional-filtering).
13
+
12
14
## Attribute Syntax
13
15
14
16
The basic syntax was inspired by [Kramdown](http://kramdown.gettalong.org/syntax.html#attribute-list-definitions)'s Attribute Lists feature.
@@ -75,8 +77,12 @@ use League\CommonMark\Extension\Attributes\AttributesExtension;
75
77
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
76
78
use League\CommonMark\MarkdownConverter;
77
79
78
-
// Define your configuration, if needed
79
-
$config = [];
80
+
// Example custom configuration
81
+
$config = [
82
+
'attributes' => [
83
+
'allow' => ['id', 'class', 'align'],
84
+
],
85
+
];
80
86
81
87
// Configure the Environment with all the CommonMark parsers/renderers
As of version 2.7.0, this extension can be configured by providing a `attributes` array with nested configuration options.
102
+
103
+
### `allow`
104
+
105
+
An array of allowed attributes. An empty array `[]` (default) allows virtually all attributes.
106
+
107
+
**Note:** Attributes starting with `on` (e.g. `onclick` or `onerror`) are capable of executing JavaScript code and are therefore **never allowed by default**. You must explicitly add them to the `allow` list if you want to use them.
0 commit comments