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

Security advisory for AtheMathmo/rulinalg#201 #319

Merged
merged 3 commits into from
Jul 5, 2020

Conversation

Qwaz
Copy link
Contributor

@Qwaz Qwaz commented Jun 29, 2020

The affected version of rulinalg has incorrect lifetime boundary definitions for RowMut::raw_slice and RowMut::raw_slice_mut. They do not conform with Rust's borrowing rule and allows the user to create multiple mutable references to the same location.

AtheMathmo/rulinalg#201

The incorrectness of raw_slice_mut() is straightforward. However, I'm not completely sure about raw_slice(). Naively downgrading mut refs to shared refs is semantically incorrect, and that's why I think raw_slice() should be fixed, too. However, I'm not completely sure about it and any input to this is appreciated.

Also, there was a comment in the original issue that recommends nalgebra instead of rulinalg. Maybe we need to consider filing an informational advisory for that.

Copy link
Member

@Shnatsel Shnatsel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'd also include something about what violation of aliasing rules can actually result in, something like

This can lead to a variety of memory safety issues, including use-after-free, which may allow arbitrary code execution.

Thanks for reporting this issue, and for the audit!

@Qwaz
Copy link
Contributor Author

Qwaz commented Jun 30, 2020

I have reflected the feedback and created a new commit. I agree that it's possible to cause use-after-free and arbitrary code execution with complicated element type. However, considering that most users will use this library with numeric types, I think it might scare the users too much.

I tried to tone down your suggestion a little bit. Please share your thoughts if you have additional feedback or merge this if it looks good, thanks! :)

@Shnatsel
Copy link
Member

Shnatsel commented Jul 1, 2020

Ah, this makes the issue less severe than I originally thought. Thanks for clarifying!

@Shnatsel
Copy link
Member

Shnatsel commented Jul 4, 2020

Sorry for the delay on this PR.

I agree that it's possible to cause use-after-free and arbitrary code execution with complicated element type. However, considering that most users will use this library with numeric types, I think it might scare the users too much.

Do you think this warrants downgrading to informational then? Right now the severity of it as a vulnerability kind of conflicts with the relatively benign description.

Other than that LGTM

@Qwaz
Copy link
Contributor Author

Qwaz commented Jul 5, 2020

Do you think this warrants downgrading to informational then?

It's hard to tell whether a bug should get a security advisory or an informational advisory without (possibly provisional) shared standard for them. I'm opening a PR as a security advisory if we need to restrict the users of a library in a non-trivial way because of the security impact of a bug. This might be different than other people's standard, and the "non-trivial" part is also unfortunately subjective.

If this library was used with BigInt, which internally allocates, it may introduce an exploitable bug to the end user. The exact pattern to trigger the bug will be admittedly uncommon even in that case, but I think that's the nature of library bugs. (a bug triggered by an integer overflow requires an overflowing input, an injection bug requires the program to pass an attacker-controlled input to the vulnerable function, etc.)

In summary, my position is:

  • Is this a security bug?
    • Yes, and I'm strongly against saying "this is a non-security bug" or "this is not a vulnerability"
    • It means the bug has security implication, not something like "you shouldn't use this library"
  • Is this bug severe enough to get a security advisory than an informational advisory?
    • Hard to tell without the definition of "severe enough". I'm fine with either choice as long as there is consistency.
    • If RustSec maintainers or the library author think that this bug should get an informational advisory, I can update the PR.

@Shnatsel
Copy link
Member

Shnatsel commented Jul 5, 2020

Ah, so there is arbitrary code execution potential in here. This has to be enough for an advisory. I'll merge it as-is then. Thanks again!

@Shnatsel Shnatsel merged commit fb8d644 into rustsec:master Jul 5, 2020
@Qwaz
Copy link
Contributor Author

Qwaz commented Jul 6, 2020

Thank you :)

@Qwaz Qwaz deleted the rulinalg-201 branch August 20, 2020 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants