# CVE-2023-38690: matrix-appservice-irc IRC command injection via admin commands containing newlines

> Attackers can inject IRC commands via crafted channel names, leading to code execution on the bridge bot.

- **Severity:** Medium 5.8 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 4 Aug 2023
- **Updated:** 8 Oct 2024
- **Also known as:** GHSA-3pmj-jqqp-2mj3

## What is CVE-2023-38690?

CVE-2023-38690 is a medium-severity command injection vulnerability in matrix-org matrix-appservice-irc, published on 4 Aug 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

matrix-appservice-irc is a Node.js IRC bridge for Matrix. Prior to version 1.0.1, it is possible to craft a command with newlines which would not be properly parsed. This would mean you could pass a string of commands as a channel name, which would then be run by the IRC bridge bot. Versions 1.0.1 and above are patched. There are no robust workarounds to the bug. One may disable dynamic channels in the config to disable the most common execution method but others may exist.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-20 (Improper Input Validation)

## Which versions are affected by CVE-2023-38690?

2 open source packages ship an affected version, including matrix-appservice-irc. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `matrix-appservice-irc` | npm | All versions | 1.0.1 |
| `matrix-appservice-irc` | npm | All versions | 1.0.1 |

Products: Matrix Matrix Irc Bridge.

## How do I fix CVE-2023-38690?

Upgrade matrix-appservice-irc to 1.0.1 or later.

## Is CVE-2023-38690 being exploited?

There is no known exploitation of CVE-2023-38690 in the wild and no public exploit code.

## Other vulnerabilities in matrix-org matrix-appservice-irc

- [CVE-2022-39203](https://insights.sbomify.com/CVE-2022-39203/): Parsing issue in matrix-org/node-irc leading to room takeovers (high 8.8)
- [CVE-2022-29166](https://insights.sbomify.com/CVE-2022-29166/): Improper handling of multiline messages in matrix-appservice-irc (high 8.0)
- [CVE-2022-3971](https://insights.sbomify.com/CVE-2022-3971/): matrix-appservice-irc PgDataStore.ts sql injection (medium 4.6)
- [CVE-2022-39202](https://insights.sbomify.com/CVE-2022-39202/): IRC mode parameter confusion in matrix-appservice-irc (medium 4.3)
- [CVE-2023-38700](https://insights.sbomify.com/CVE-2023-38700/): matrix-appservice-irc events can be crafted to leak parts of targeted messages from other bridged rooms (low 3.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-38690 and fix it if it is affected.

What it is: CVE-2023-38690 is a medium-severity command injection vulnerability in matrix-org matrix-appservice-irc, published on 4 Aug 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-38690 in the wild and no public exploit code.

Affected packages and fixed versions:
- matrix-appservice-irc (npm): affected all versions; fixed in 1.0.1
- matrix-appservice-irc (npm): affected all versions; fixed in 1.0.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-38690/ (Markdown: https://insights.sbomify.com/CVE-2023-38690/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-38690
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-38690
- OSV: https://osv.dev/vulnerability/CVE-2023-38690

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-38690/
Summaries are generated and may contain mistakes; the official description above is the record.
