Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong serialization of error messages. #620

Closed
mmartinv opened this issue Feb 15, 2024 · 1 comment · Fixed by #629
Closed

Wrong serialization of error messages. #620

mmartinv opened this issue Feb 15, 2024 · 1 comment · Fixed by #629
Labels
bug Something isn't working conformance-test Issues related to passing the FIDO Aliance conformance tests jira protocol Anything to do with the T0/T1/T2 protocols spec-nonconformity Bits where we aren't following the exact specification

Comments

@mmartinv
Copy link
Contributor

It looks like the error messages are not being serialized correctly.

From the conformance server I can see the following error message as the response for a bad formatted request (in hex format):

a56a6572726f725f636f646518647570726576696f75735f6d6573736167655f74797065146c6572726f725f737472696e67784553657269616c697a6174696f6e206572726f723a20696e76616c696420747970653a20696e7465676572206030602c206578706563746564207374727563742048656c6c6f6f6572726f725f74696d657374616d70f66a6572726f725f757569641b55413d158cba1b93

The conformance server fails parsing the above data with:

cbor: cannot unmarshal map into Go value of type fdoshared.FdoError (cannot decode CBOR map to struct with toarray option)

Using the playground site (http://cbor.me ) to decode the content by pasting it in the Bytes text box (on the right side) and clicking on the green arrow above that text box (convert to diagnostic notation), the following is shown:

  • In the Diagnostic text box, the deserialized data is:
{"error_code": 100, "previous_message_type": 20, "error_string": "Serialization error: invalid type: integer `0`, expected struct Hello", "error_timestamp": null, "error_uuid": 6143258529474681747}
  • In the Bytes text box the pasted content is formatted in the following way:
A5                                      # map(5)
   6A                                   # text(10)
      6572726F725F636F6465              # "error_code"
   18 64                                # unsigned(100)
   75                                   # text(21)
      70726576696F75735F6D6573736167655F74797065 # "previous_message_type"
   14                                   # unsigned(20)
   6C                                   # text(12)
      6572726F725F737472696E67          # "error_string"
   78 45                                # text(69)
      53657269616C697A6174696F6E206572726F723A20696E76616C696420747970653A20696E7465676572206030602C206578706563746564207374727563742048656C6C6F # "Serialization error: invalid type: integer `0`, expected struct Hello"
   6F                                   # text(15)
      6572726F725F74696D657374616D70    # "error_timestamp"
   F6                                   # primitive(22)
   6A                                   # text(10)
      6572726F725F75756964              # "error_uuid"
   1B 55413D158CBA1B93                  # unsigned(6143258529474681747)

According to the FIDO specification the error message definition seems to be an array of elements:

ErrorMessage = [
    EMErrorCode: uint16,   ;; Error code
    EMPrevMsgID: uint8,    ;; Message ID of the previous message
    EMErrorStr:  tstr,     ;; Error string
    EMErrorTs:   timestamp,;; UTC timestamp
    EMErrorCID: correlationId ;; Unique id associated with this request
]
timestamp = null / UTCStr / UTCInt / TIME_T
UTCStr = #6.0(tstr)
UTCInt = #6.1(uint)
TIMET  = #6.1(uint)
correlationId = uint

Therefore, the conformance server error would make sense as we are formatting the Error as a CBOR map instead of an CBOR array.

@mmartinv mmartinv added bug Something isn't working spec-nonconformity Bits where we aren't following the exact specification jira protocol Anything to do with the T0/T1/T2 protocols conformance-test Issues related to passing the FIDO Aliance conformance tests labels Feb 15, 2024
@nullr0ute
Copy link
Contributor

It would be worth while looking at git history here, I seem to remember there was previous back and forth around cbor serialisation, could also be a bug/change in rust dependencies.

@7flying 7flying added this to the Interop testing milestone Feb 20, 2024
mmartinv added a commit to mmartinv/fido-device-onboard-rs that referenced this issue Feb 27, 2024
Use `serde_tuple` to serialize/deserialize the error messages
as a CBOR arrays instead of a CBOR maps as described in the
FIDO Device Onboard Specification.

Fixes: fdo-rs#620

Signed-off-by: Miguel Martín <mmartinv@redhat.com>
mmartinv added a commit to mmartinv/fido-device-onboard-rs that referenced this issue Feb 29, 2024
Use `serde_tuple` to serialize/deserialize the error messages
as a CBOR arrays instead of a CBOR maps as described in the
FIDO Device Onboard Specification.

Fixes: fdo-rs#620

Signed-off-by: Miguel Martín <mmartinv@redhat.com>
mmartinv added a commit to mmartinv/fido-device-onboard-rs that referenced this issue Feb 29, 2024
Use `serde_tuple` to serialize/deserialize the error messages
as a CBOR arrays instead of a CBOR maps as described in the
FIDO Device Onboard Specification.

Fixes: fdo-rs#620

Signed-off-by: Miguel Martín <mmartinv@redhat.com>
mmartinv added a commit to mmartinv/fido-device-onboard-rs that referenced this issue Feb 29, 2024
Use `serde_tuple` to serialize/deserialize the error messages
as a CBOR arrays instead of a CBOR maps as described in the
FIDO Device Onboard Specification.

Fixes: fdo-rs#620

Signed-off-by: Miguel Martín <mmartinv@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working conformance-test Issues related to passing the FIDO Aliance conformance tests jira protocol Anything to do with the T0/T1/T2 protocols spec-nonconformity Bits where we aren't following the exact specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants