[Bug]: OPC UA UserNameIdentityToken sends length+password+nonce instead of the plain password when token security policy is None
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 1.8k
- Fork
- 514
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/plc4x
-
[Bug]: eip.mspec formationĐang mởEthernet/IP java
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/plc4x#2733 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: [Modbus] Support UDINT with least significant register first (little-endian word order)Đang mởjava Modbus
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
apache/plc4x#2837 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
java Modbus
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: TagBatch reuses a cached PlcReadRequest bound to a closed connection, so fetches fail after the first and never recover after a PLC restartCó thể đã có người làm @chrisdutz đã nhận 12 ngày trước. Đang mởjava Modbus
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
apache/plc4x#2832 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: OPC-UA driver 1.0.0 fails against a certificate-less server even with security-policy=NONE (regression vs 0.13.1)Có thể đã có người làm @splatch đã nhận 16 ngày trước. Đang mởjava OPC-UA
apache/plc4x#2830 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug subsystem:agent-harness triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ShaftHQ/SHAFT_ENGINE#7797 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ARM: Q flag should be stickyĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
NationalSecurityAgency/ghidra#10155 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug web-ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
jenkinsci/jenkins#27705 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
"item-tooltip-keyboard-fix" crashes the game when opening the Items tab of the statistics menuĐang mởmod bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
elmital/FixMCStats#65 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
QuranHub/quranhub-android#354 ·
Maintainer thường phản hồi trong vòng 2 ngày