Summary
Netmaker's Authorize middleware previously accepted any valid host JWT as sufficient proof of access, without checking whether the host was authorized for the specific resource being requested.
An attacker with a valid host token and knowledge of object identifiers (such as node or host IDs) could use this flaw to read, modify, or delete resources belonging to other hosts across multiple management endpoints.
Affected context
This vulnerability arises in Netmaker deployments that:
- Use JWT-based host authentication via the Authorize middleware
- Expose API routes configured with
hostAllowed=true - Rely on the middleware to both authenticate and authorize host access to specific resources
In such contexts, endpoints dealing with node information, host lifecycle operations, MQTT signaling, fallback host configuration, and failover behavior may be affected when authorization is not tied to resource ownership.
Exploit preconditions
- Attack surface: Netmaker API endpoints that accept host authentication (
hostAllowed=true). - Required access: Ability to obtain any valid host JWT token (e.g., from a compromised host, leaked token, or misconfigured environment).
- Knowledge required: Identifiers of target resources (such as node IDs, host IDs, or other object keys exposed via logs, API responses, or guessable patterns).
- Trigger point: Sending crafted HTTP requests to affected endpoints with:
- A valid host JWT in the appropriate authorization header
- Path or payload parameters referencing resources owned by other hosts
- Why exploitation is possible: The middleware validates the JWT as a host token but does not enforce per-resource authorization; once
hostAllowed=truepasses, subsequent checks do not confirm that the token's host identity matches the resource owner.
Why this happens
The core issue is an authorization design flaw rather than broken authentication.
The Authorize middleware correctly verifies host JWT validity, but it treats that as sufficient for access to any route where hostAllowed=true. It does not consistently:
- Bind the authenticated host identity from the token to the resource being accessed, or
- Enforce ownership checks (e.g., comparing host ID in JWT claims to the host/node ID in the request).
This maps to CWE-863: Incorrect Authorization, where the application validates a subject's identity but fails to verify that the subject is permitted to perform the requested action on the specific target resource.
As a result, possession of any valid host token effectively becomes a broad capability, allowing cross-tenant or cross-host operations when object identifiers are known or discoverable.
Potential impact
- Unauthorized retrieval of node and host configuration data belonging to other hosts
- Unauthorized deletion of other hosts, potentially disrupting network topology and connectivity
- Unauthorized sending of MQTT signals that could trigger unintended actions in other hosts
- Unauthorized changes to fallback host settings and failover behavior, impacting resilience and routing
- Lateral movement within the managed network by manipulating other hosts' resources and roles
- Denial-of-service conditions by mass-deleting or misconfiguring remote hosts
General mitigation guidance
Effective mitigation focuses on enforcing strict, resource-level authorization and reducing the power of any single host token:
- Bind identities to resources: Ensure that handlers and middleware consistently verify that the host identity in the JWT (e.g., host ID claim) matches the resource owner in the request path, query, or payload.
- Separate authentication and authorization: Treat JWT validation as authentication only; apply explicit, centralized authorization checks for each sensitive action and resource type.
- Adopt least privilege for host tokens: Limit host JWT scopes to the minimal set of operations and resources required; favor narrow, purpose-built claims over broad, implicit access.
- Normalize access patterns: Use standard authorization patterns such as policy engines (e.g., attribute-based or role-based checks) so that new endpoints inherit secure defaults rather than ad-hoc checks.
- Harden token management: Reduce the risk of token reuse by implementing reasonable lifetimes, rotation, and revocation mechanisms.
- Improve multi-tenant isolation: Treat each host or group of hosts as isolated tenants, ensuring that cross-tenant references are rejected by default unless explicitly allowed.
How teams detect issues like this
Detection can combine code-level review with runtime monitoring:
- Static analysis and code review:
- Flag handler functions or routes marked with
hostAllowed=truethat do not: - Compare host IDs from JWT claims with IDs in path or payload, or
- Invoke a common authorization helper/policy.
- Look for patterns where JWT validation success directly leads to resource access without checking ownership.
- Enforce architectural rules (via linters or custom checks) that all resource-modifying endpoints must call shared authorization routines.
- Automated security testing:
- Use API security scanners or fuzzers to replay requests against endpoints with swapped host or node IDs, verifying if cross-host access is possible.
- Include negative test cases in CI that attempt operations on resources owned by other hosts using a single host token.
- Runtime monitoring and logging:
- Log host identity (from JWT claims) alongside target resource identifiers for sensitive operations.
- Alert on anomalies, such as one host token frequently accessing or altering many distinct host IDs or nodes.
- Policy enforcement tooling:
- Integrate authorization policy engines (e.g., OPA/ABAC frameworks) that can be analyzed and tested centrally, reducing the chance of per-endpoint omissions.

