Security Best Practices¶
This guide covers security considerations for aiohomematic and the Homematic(IP) Local integration.
Overview¶
aiohomematic communicates with your Homematic backend (CCU/Homegear) using XML-RPC and JSON-RPC protocols. Securing this communication protects your smart home from unauthorized access.
Backend Security is Critical
CCU, OpenCCU (RaspberryMatic), and Homegear have had serious security vulnerabilities in the past, including unauthenticated remote code execution. Never expose your backend to the internet and keep firmware updated.
Known Backend Vulnerabilities¶
Critical: Never Expose to Internet¶
Homematic backends (CCU2, CCU3, OpenCCU, Homegear) are not designed for internet exposure. Historical vulnerabilities include:
| Year | Affected | Issue | Severity |
|---|---|---|---|
| 2024 | RaspberryMatic ≤3.73.9 | Unauthenticated RCE via ZipSlip | Critical |
| 2020 | CCU2/CCU3 WebUI | Unauthenticated RCE as root | Critical |
| 2019 | CCU3 | Local File Inclusion (CVE-2019-9726) | High |
| 2019 | CCU2/CCU3 + XML-API | Unauthenticated RCE via exec.cgi | Critical |
| 2019 | CCU2/CCU3 | Session fixation, password hash disclosure | High |
| 2019 | CCU2/CCU3 + CUxD | Admin operations without authentication | Critical |
Required Actions¶
- Keep firmware updated - Install security patches immediately
- Never port-forward CCU ports - Use VPN for remote access
- Isolate on separate VLAN - Limit blast radius of potential compromise
- Enable authentication - Even on internal network
- Remove unused add-ons - XML-API, CUxD have had vulnerabilities
Checking Your Version¶
CCU/OpenCCU:
- CCU WebUI → Settings → Control Panel → System
- Check firmware version
- Compare with latest OpenCCU release
Homegear:
Security Advisories¶
Monitor these sources for new vulnerabilities:
Authentication¶
CCU Authentication¶
Always enable authentication on your CCU:
- CCU WebUI → Settings → Control Panel → Security
- Enable Authentication
- Create a dedicated user for Home Assistant
User Requirements¶
| Requirement | Details |
|---|---|
| Privileges | Administrator role required |
| Username | Case-sensitive, use exactly as shown in CCU |
| Password | See allowed characters below |
Password Requirements¶
Only these characters are supported in passwords:
Not supported:
- Umlauts:
Ä ä Ö ö Ü ü ß - Other special characters:
@ & * % ^ ~ - Unicode characters
These work in CCU WebUI but fail via XML-RPC.
TLS Configuration¶
Enabling TLS¶
-
Enable TLS on CCU first:
-
CCU WebUI → Settings → Control Panel → Security
-
Enable HTTPS
-
Configure integration:
- Enable "Use TLS" in integration settings
- Set "Verify TLS" based on certificate type
Certificate Types¶
| Certificate Type | Verify TLS Setting | Notes |
|---|---|---|
| Self-signed (default) | false | CCU default, no chain verification |
| Let's Encrypt | true | Valid chain, full verification |
| Custom CA | true | Must add CA to system trust store |
TLS Ports¶
| Interface | Plain Port | TLS Port |
|---|---|---|
| HmIP-RF | 2010 | 42010 |
| BidCos-RF | 2001 | 42001 |
| BidCos-Wired | 2000 | 42000 |
| Virtual Devices | 9292 | 49292 |
| JSON-RPC | 80 | 443 |
Network Security¶
Firewall Configuration¶
Inbound to CCU (from Home Assistant):
| Port | Protocol | Service |
|---|---|---|
| 80/443 | TCP | JSON-RPC (names, rooms, sysvars) |
| 2001/42001 | TCP | BidCos-RF |
| 2010/42010 | TCP | HmIP-RF |
| 2000/42000 | TCP | BidCos-Wired (if used) |
| 9292/49292 | TCP | Virtual Devices (if used) |
Inbound to Home Assistant (from CCU):
| Port | Protocol | Service |
|---|---|---|
| Callback port | TCP | XML-RPC callbacks (configurable) |
Network Segmentation¶
Recommended network architecture:
Internet
│
▼
┌─────────────────┐
│ Router/FW │ ← No inbound from internet
└────────┬────────┘
│
┌────┴────┐
│ │
▼ ▼
┌───────┐ ┌───────┐
│ IoT │ │ Main │
│ VLAN │ │ LAN │
│ │ │ │
│ CCU │ │ HA │ ← Allow CCU ↔ HA only
│ │ │ │
└───────┘ └───────┘
Docker Security¶
For Docker installations:
Recommended: Use network_mode: host
Alternative (Bridge Network):
- Set
callback_hostto Docker host IP - Only expose callback port (not all CCU ports)
- Use internal Docker network where possible
services:
homeassistant:
network_mode: host # Recommended for callback support
# OR with bridge:
ports:
- "8123:8123" # HA UI
- "43439:43439" # Callback port only
Secrets Management¶
Never Commit Credentials¶
Exclude from version control:
Home Assistant Secrets¶
Use secrets.yaml:
# secrets.yaml (not in version control)
ccu_password: your-secure-password
# configuration.yaml
homematic:
password: !secret ccu_password
Environment Variables¶
For standalone library use:
import os
from aiohomematic.api import HomematicAPI
async with HomematicAPI.connect(
host=os.environ["CCU_HOST"],
username=os.environ["CCU_USER"],
password=os.environ["CCU_PASSWORD"],
) as api:
...
Access Control¶
Principle of Least Privilege¶
- Create dedicated CCU user for Home Assistant
- Don't use main admin account
- Disable CCU user when not in use (maintenance)
Network Access¶
- Restrict CCU management interface to trusted IPs
- Use VPN for remote access (not port forwarding)
- Monitor CCU access logs
Security Checklist¶
| Check | Status |
|---|---|
| CCU authentication enabled | [ ] |
| Dedicated user for HA created | [ ] |
| Password uses only allowed characters | [ ] |
| TLS enabled (if possible) | [ ] |
| Firewall rules configured | [ ] |
| No CCU ports exposed to internet | [ ] |
| secrets.yaml for credentials | [ ] |
| Regular CCU firmware updates | [ ] |
Common Security Issues¶
Issue: "Authentication failed"¶
Causes:
- Wrong username/password
- Password contains unsupported characters
- User lacks admin privileges
Solution:
- Verify credentials in CCU WebUI
- Check password for special characters
- Verify user role is Administrator
Issue: Callbacks not working¶
Causes:
- Firewall blocking CCU → HA
- Incorrect callback_host setting
Solution:
- Ensure CCU can reach HA on callback port
- Set callback_host to HA's IP (not localhost)
- Check Docker network configuration
Reporting Security Issues¶
Report security vulnerabilities privately:
- Do not open public GitHub issues for security bugs
- Contact maintainers directly via GitHub security advisories
- Allow time for fix before public disclosure
Related Documentation¶
- Troubleshooting - Connection issues
- CUxD and CCU-Jack - MQTT security
- User Guide - Configuration