[Bug]: OPC UA UserNameIdentityToken sends length+password+nonce instead of the plain password when token security policy is None
I maintainer di solito rispondono entro 1 giorno
@splatch ci sta già lavorando.
Dal 2/10/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
What happened?
With PLC4J 1.0.0, the OPC UA driver cannot log in with username/password when the selected user token policy resolves to security policy None (and allow-insecure-credentials=true is set). The server answers ActivateSession with BadUserAccessDenied (0x801f0000). The same server and credentials work with 0.13.1.
The cause is in SecureChannel.getIdentityToken(...) (plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java, tag v1.0.0, unchanged on develop). For userTokenTypeUserName the method builds the RSA plaintext block length(4, little endian) + password + serverNonce (encodeablePassword). In the SecurityPolicy.NONE branch that block is sent as the token password instead of the password itself:
if (tokenSecurityPolicy == SecurityPolicy.NONE) {
// No encryption: the password is sent as-is and no algorithm is declared.
tokenPassword = encodeablePassword; // should be passwordBytes
encryptionAlgorithm = "";
}
OPC UA Part 4, 7.41.3 (UserNameIdentityToken): when encryptionAlgorithm is empty the password field carries the UTF-8 password itself; the length/nonce wrapping only applies to the encrypted form. A spec-conforming server therefore compares <4 length bytes> + password + nonce with the stored password and rejects the login. The code comment says "the password is sent as-is", so this looks like the wrong local variable.
Steps to reproduce
- OPC UA server that exposes a
Noneendpoint with aUserNameuser token policy without its ownsecurityPolicyUriand requires authentication (we used pythonasyncua1.1.5 with a user manager that compares username/password in plain text). - Connect with
opcua:tcp://host:port?discovery=false&security-policy=NONE&allow-insecure-credentials=true&username=u&password=pand read any node. - Connection fails with
PlcProtocolException: Server returned error BadUserAccessDenied (0x801f0000). On the server side the received password is 4 + len(password) + 32 bytes long.
Expected
The token password is the plain UTF-8 password when no encryption algorithm is declared, as in 0.13.1, and the login succeeds.
Suggested fix
In the SecurityPolicy.NONE branch use tokenPassword = passwordBytes; (and only build encodeablePassword for the encrypted branch).
Version
1.0.0 (Java, plc4j-driver-opcua), JDK 21.
- Lingua principale
- Java
- Stelle
- 1.8k
- Fork
- 510
- Merge medio
- 1g 12h
- PR unite (30g)
- 45
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/plc4x
-
[Bug]: eip.mspec formationApertaEthernet/IP java
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
apache/plc4x#2733 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
ADS java
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
java OPC-UA
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
apache/plc4x#2744 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
S7: reading a BOOL array fails with NullPointerException in PlcBOOL.of, tag returns INTERNAL_ERRORApertaS7
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
apache/plc4x#2742 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/plc4x
Issue simili
-
False Negative: InnerTypeLastCheck does not report members declared after inner enums or annotationsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
checkstyle/checkstyle#22027 ·
I maintainer di solito rispondono entro 1 giorno
-
bug follow-up lane:auto
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Sanne/incus-spawn#1497 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[CI] NettyClientTest.testServerDisconnection may fail with DisconnectExceptionForse già presa @yangshangqing95 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100