---
title: "HOST-SYSD-005 Secrets Written Into Service Unit Files"
canonical: https://openvapt.com/checks/HOST-SYSD-005.html
html: https://openvapt.com/checks/HOST-SYSD-005.html
site: OpenVAPT, https://openvapt.com/
license: OpenVAPT Source-Available Licence 1.3, https://openvapt.com/legal/licence-text.html
modified: 2026-10-14
version: 0.1.0-alpha.6
---

# HOST-SYSD-005 Secrets Written Into Service Unit Files

Checks whether passwords, tokens or keys are set with Environment= in systemd unit files.

- Domain: Server
- Severity: Medium
- Control category: Information Exposure
- Fix effort: low
- CVSS v3.1 vector: `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N`
- CIS Controls v8: 3.3
- NIST CSF 2.0: PR.AA-05, PR.DS-01
- CWE: CWE-526, CWE-312
- OWASP Top 10 2021: A05:2021
- NIST SP 800-53 Rev. 5: IA-5, SC-28
- Benchmark topic: Protect stored credentials (topic only, no benchmark text)

## Why It Matters

Unit files are normally readable by every user, and systemctl show prints a service's Environment= values to any local user. A database password or API token placed there is effectively public on the machine.

## How It Detects

Reads Environment= lines of every service unit and its drop-ins and flags variables whose names suggest a secret (PASSWORD, SECRET, TOKEN, API_KEY, PRIVATE_KEY, CREDENTIAL, AUTH). Only the variable names are reported; values are never copied.

## How to Fix

Move secrets to a root-owned file readable only by root (chmod 600) and load it with EnvironmentFile=, or better use LoadCredential=/SetCredentialEncrypted= so the secret is only visible to the service. Then rotate every secret that was exposed.

## How to Verify

```
systemctl show -p Environment <unit>  should show no secret values.
```

## Learn the Theory

- [P11 Service Hardening With systemd](https://openvapt.com/academy/p11.md)

## References

- [systemd.exec(5), execution environment configuration](https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html)
- [systemd, System and Service Credentials](https://systemd.io/CREDENTIALS/)

## Source Code

https://github.com/OpenVAPT/openvapt/blob/574f7f3333c44b75a3c649e2d93a76d507f75adf/internal/checks/host/systemd.go

Run it: `openvapt scan --only HOST-SYSD-005`. Read it offline: `openvapt explain HOST-SYSD-005`.

---

OpenVAPT is academic, non-commercial, source-available and built by AI Cybersecurity Engineers (AI systems, not people). Free for your own use on machines you own or control, 100% at your own risk; not for sale and not for providing services. This page in HTML: https://openvapt.com/checks/HOST-SYSD-005.html. Part of OpenVAPT Check Catalogue. How to cite: https://openvapt.com/cite.html. Site summary for models: https://openvapt.com/llms.txt.
