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

CodeQL warnings #42

Open
aido opened this issue Apr 6, 2023 · 4 comments · May be fixed by #44
Open

CodeQL warnings #42

aido opened this issue Apr 6, 2023 · 4 comments · May be fixed by #44
Assignees

Comments

@aido
Copy link

aido commented Apr 6, 2023

Hi,

I am using bc-shamir in an application I am writing to generate SSKR shares on Ledger hardware wallet devices: SSKR Check
CodeQL is giving a couple of warnings about bc-shamir which maybe you would like to be aware of.

See here:

https://github.com/aido/app-sskr-check/security/code-scanning/11
or here:
https://codeql.github.com/codeql-query-help/cpp/cpp-comparison-with-wider-type/

for(uint8_t j=0; j<share_length; ++j) {

and here:

https://github.com/aido/app-sskr-check/security/code-scanning/12

for(uint8_t j=0; j<secret_length; ++j) {

@wolfmcnally
Copy link
Collaborator

Unfortunately the issue links above are now returning a 404. Can you either provide updated links or at least describe the warning you're receiving?

Also, I notice you're not using our original repos for SSKR or Shamir, but if you do have a simple code fix for any warnings you're receiving, we'd love it if you could file a PR on the original repos!

@aido
Copy link
Author

aido commented May 2, 2023

Hi @wolfmcnally,

The links above seem to still work fine for me so I think github may be blocking public access to security warnings generated by Code QL. I have added you as a colaborator on the app-sskr-check repo so hopefully the links work now.

The gist of the warnings are that In a loop condition, comparison of a value of a narrow type with a value of a wide type may result in unexpected behavior if the wider value is sufficiently large (or small). This is because the narrower value may overflow. This can lead to an infinite loop. i.e. a uint8_t being compared to a uint32_t in a loop condition in line 79 and 142 of shamir.c

A simple fix would be to cast uint32_t share_length and uint32_t secret_length to uint8_t or question why share_length and secret_length are uint32_t to begin with.

aido added a commit to aido/bc-shamir that referenced this issue May 4, 2023
@aido aido linked a pull request May 4, 2023 that will close this issue
@ChristopherA
Copy link
Contributor

@wolfmcnally status?

@wolfmcnally
Copy link
Collaborator

I'll review his PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 2023 Q2 Done
Development

Successfully merging a pull request may close this issue.

3 participants