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

Validation always fails for CBOR with non-standard simple values #90

Open
Anrock opened this issue Aug 30, 2021 · 6 comments · Fixed by #95
Open

Validation always fails for CBOR with non-standard simple values #90

Anrock opened this issue Aug 30, 2021 · 6 comments · Fixed by #95
Assignees
Labels
bug Something isn't working cbor dependency
Milestone

Comments

@Anrock
Copy link

Anrock commented Aug 30, 2021

Seems like cddl is unable to validate any CBOR binary that uses non-standard simple values, instead producing

Validation of "filename.cbor" failed

error parsing cbor: unassigned type at offset X

As far as I understand this is due to serde_cbor intentionally producing parser error when it encounters any simple value it doesn't understand.

Is there any workaround for that or the fix would be to replace serde_cbor with other library?

@anweiss
Copy link
Owner

anweiss commented Aug 30, 2021

hey @Anrock, thanks for highlighting this. Indeed, this is due to error in the serde_cbor library as you indicated. Given that https://github.com/pyfisch/cbor is now archived and no longer being maintained, I plan to replace it with a different library.

@anweiss anweiss added cbor bug Something isn't working labels Aug 30, 2021
@anweiss anweiss self-assigned this Aug 30, 2021
@anweiss anweiss added this to the v1.0.0 milestone Aug 30, 2021
@Anrock
Copy link
Author

Anrock commented Nov 29, 2021

@anweiss not sure if it's fixed with ciborium. I just compiled 8d398da and tried to validate same cbor against cddl spec and got

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Semantic(None, "invalid type: simple, expected known simple value")', src/validator/mod.rs:169:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Seems like it's the same thing with ciborium too - it intentionally produces an error on any custom simple value it doesn't know about

@anweiss
Copy link
Owner

anweiss commented Nov 29, 2021

hey @Anrock, can you provide the CDDL you are using that is causing this error?

@anweiss anweiss reopened this Nov 29, 2021
@Anrock
Copy link
Author

Anrock commented Nov 29, 2021

@anweiss I don't think it's the CDDL itself but a cbor binary. Minimal repro should be just a simple value from unassigned range, like 40 or 41 (CDDL #7.40 or #7.41). I'll try to get minimal repro tomorrow.

@Anrock
Copy link
Author

Anrock commented Nov 30, 2021

@anweiss okay, I got minimal repro.

cddl: root = #7.32

cbor: f820.

I don't think I can attach a binary file in github, but you can easily create it via echo f820 | xxd -p -r > min.cbor

Then running ./cddl validate --cddl min.cddl --cbor min.cbor will produce

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Semantic(None, "invalid type: simple, expected known simple value")', src/validator/mod.rs:169:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@anweiss
Copy link
Owner

anweiss commented Oct 27, 2022

Thanks @Anrock for reporting this. Putting this in the backlog until enarx/ciborium#60 is looked at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cbor dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants