GHSA-P68V-69QC-9345
DKIM selector injection in rspamd selector map via relay domain API
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-P68V-69QC-9345 divulgada · CVSS 2.7 (GitHub) | |
| Remediación | Parche 2.13.0 | modoboa · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The relay domain API endpoint accepts an unvalidated `dkim_key_selector`,
which is written verbatim into the rspamd DKIM selector map. A user with
the Reseller role can embed a carriage return in the selector to inject a
map entry overriding the DKIM selector of a domain owned by another
tenant, breaking DKIM signing for that domain. This is an incomplete fix
of the selector validation introduced in 2.9.1, which only covered the
regular domain API.
Details
`DomainSerializer` (`modoboa/admin/api/v1/serializers.py`, also used by
API v2) restricts `dkim_key_selector` to `[A-Za-z0-9._-]+` since 2.9.1.
`RelayDomainSerializer` (`modoboa/relaydomains/api/v1/serializers.py`)
exposes the same model field as writable but has no such validator, and
the `Domain.dkim_key_selector` model field itself carries no validation
(only `max_length=30`).
When a domain with DKIM enabled is saved, `rspamd.jobs.update_rspamd_maps`
rewrites the selector map with one `<domain> <selector>` line per domain.
The selector is only sanitized with `.replace("\n", "")`, so a `\r` is
written to the file unchanged.
On the next map update, `MapsUpdater.load_map` reads the file in Python
text mode (universal newlines), where `\r` is a line terminator. The line
attacker.test a\rvictim.com evilsel
is therefore parsed as two entries, `attacker.test -> a` and
`victim.com -> evilsel`. The injected entry overrides the legitimate one
for `victim.com` and is persisted on the next write. It stays in place
until `victim.com` itself is modified, which rewrites its entry.
The DKIM private key map is not affected (`dkim_private_key_path` is
read-only in the API), so rspamd signs mail for `victim.com` with the
correct key but a wrong selector, and DKIM verification fails.
A selector containing a space (`"a b"`) produces a line with three fields;
it is discarded as malformed and only breaks the attacker's own entry.
Requirements: rspamd integration enabled with DKIM selector and key maps
configured, and an account allowed to create or change domains (Reseller
or SuperAdmin).
Proof of concept
- Log in as a Reseller and obtain an API token.
- Create a relay domain with DKIM enabled and a crafted selector
curl -s -X POST https://modoboa.example/api/v1/relaydomains/ \
-H "Authorization: Token <reseller-token>" \
-H "Content-Type: application/json" \
-d '{
"name": "attacker.test",
"enabled": true,
"enable_dkim": true,
"dkim_key_selector": "a\rvictim.com evilsel",
"transport": {"service": "relay",
"_settings": "{\"relay_target_host\": \"127.0.0.1\", \"relay_target_port\": 25}"}
}'
The API returns `201 Created`. The same payload sent to
`/api/v1/domains/` is rejected with "Enter a valid DKIM selector".
3. Once a DKIM key has been generated for the domain
(`python manage.py modo manage_dkim_keys`), the selector map contains:
attacker.test a\rvictim.com evilsel
- Trigger any later map update (for instance by saving any domain with
victim.com evilsel
Outgoing mail for `victim.com` is signed with selector `evilsel`, for
which no DNS record exists, and fails DKIM verification.
The parsing behaviour can be checked on its own:
import tempfile
p = tempfile.mktemp()
open(p, "w").write("attacker.test a\rvictim.com evilsel\n")
print([line.split() for line in open(p)])
# [['attacker.test', 'a'], ['victim.com', 'evilsel']]
Impact
The relay domain API (`/api/v1/relaydomains/`) accepted an arbitrary
`dkim_key_selector` value. This value is written verbatim into the rspamd
DKIM selector map. The selector validation added in 2.9.1 to block this
injection class was only applied to the regular domain API, and the map
writer only stripped `\n` characters.
A user allowed to create or change domains (Reseller role) could set a
selector containing a carriage return to inject an entry for a domain
belonging to another tenant into the selector map. That domain's outgoing
mail would then be signed with a wrong selector, making DKIM verification
(and potentially DMARC) fail. The private key map is not affected: an
attacker cannot sign mail on behalf of another domain.
Only installations using the rspamd integration with DKIM enabled are
affected.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypimodoboa |
Corregida | 2.13.0 | 0 d | 2.13.0 no afectada |
2.13.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/modoboa/modoboa/security/advisories/GHSA-p68v-69qc-9345Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
