# node-opcua: Namespace-Level RBAC Fail-Open - Anonymous Write/Call Bypass via Unbound `DefaultRolePermissions

node-opcua resolves namespace-default RolePermissions to null and fails open, letting anonymous OPC UA clients Write protected Variables and Call privileged Methods.

- Payout: Research
- Severity: critical
- Program: node-opcua
- Found by: Velluso
- Disclosed: 2026-11-10
- CVE: CVE-2026-95860
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-xggf-m53x-jc3f
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-xggf-m53x-jc3f
- Tags: area:oss domain:iot domain:oss impact:dos impact:integrity kind:research platform:ghsa sev:critical tech:nodejs technique:source-review vuln:access-control vuln:auth-bypass vuln:misconfiguration

**Target:** OPC UA server address space (node-opcua npm packages)
**Root cause:** getPermissionForRole(null) returns allPermissions instead of default-deny, and the enforcement path reads the DefaultRolePermissions UAVariable node while setDefaultRolePermissions() writes only a private field, so the namespace default resolves to null.
**Steps:**
1. Set namespace policy via `ns.setDefaultRolePermissions([{roleId: WellKnownRoles.Operator, permissions: makePermissionFlag("Read | Write | Browse | Call")}])` without calling setNamespaceMetaData().
2. Start OPCUAServer with `allowAnonymous: true`, SecurityPolicy.None, MessageSecurityMode.None.
3. Connect client and `createSession({ type: UserTokenType.Anonymous })`.
4. `session.call({ objectId: parentNodeId, methodId: methodNodeId, inputArguments: [] })` returns `Good (0x00000000)`.
5. `session.write({ nodeId: variableNodeId, attributeId: AttributeIds.Value, value: { value: { dataType: DataType.Double, value: 999.0 } } })` returns `Good`.
6. Control with setNamespaceMetaData() yields `BadUserAccessDenied (0x801f0000)`; on NodeSet2 namespaces setNamespaceMetaData() throws 'INamespace meta data already exists'.
**How found:** Code review of session_context.ts found getPermissionForRole(null) returning allPermissions, contradicting OPC 10000-3 §4.8.3 default-deny; tracing the enforcement path showed it reads the DefaultRolePermissions UAVariable node while setDefaultRolePermissions() writes a private field, and measured getDefaultRolePermissions() returning the policy while getApplicableRolePermissions() returned null.
**Exploitation:** Unauthenticated OPC UA client opens an Anonymous session over opc.tcp with no security policy, then issues Call on bound Methods (e.g. EmergencyShutdown, Stop) and Write on Variables (e.g. ReactorSetpoint, Setpoint), both returning Good because the namespace default resolves to null and grants allPermissions.
**Escalation:** Methods have no AccessLevel second gate and executable defaults true for bound methods, so any bound method (shutdown/reboot/role administration) is callable, raising availability impact.
**Insight:** When a config API writes to an in-memory field but enforcement reads a mirrored address-space node, test the two paths diverge: call the setter, then assert the enforcement getter, and check whether the sync step (setNamespaceMetaData) throws on nodeset-loaded namespaces, leaving no way to activate the policy.

