Skip to content

Comments

Use custom exception on params too deep error.#1838

Merged
rafaelfranca merged 1 commit intorack:2-2-stablefrom
RubyElders:custom-range-exception-2-2
Apr 4, 2022
Merged

Use custom exception on params too deep error.#1838
rafaelfranca merged 1 commit intorack:2-2-stablefrom
RubyElders:custom-range-exception-2-2

Conversation

@simi
Copy link
Contributor

@simi simi commented Apr 4, 2022

/cc @rafaelfranca

@rafaelfranca rafaelfranca merged commit 59d4440 into rack:2-2-stable Apr 4, 2022
@simi simi deleted the custom-range-exception-2-2 branch April 4, 2022 20:56
@simi
Copy link
Contributor Author

simi commented Apr 4, 2022

@rafaelfranca thanks. Are there any plans to release this with patch version bump? I can help to prepare the release. Once released, I can open the last PR to handle this exception properly in Rails.

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

This to me looks like a breaking change for existing Rack 2.x - @jeremyevans what do you think?

@simi
Copy link
Contributor Author

simi commented Apr 6, 2022

@ioquatix As I have pointed at #1837, specs are passing with no change (even I have changed them to use the new exception). New exception is inherited from the old one. Can you elaborate a little more what do you think is breaking change in here?

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

Ah yes, I missed that you subclassed RangeError, it might be acceptable then. I think it might have been good to retain the existing specs since that shows that it's still compatible with the original expectations. Looking at the specs, it looks like it's completely different class.

@simi
Copy link
Contributor Author

simi commented Apr 6, 2022

I can add additional spec to ensure ParamsTooDeepError inherits from RangeError if welcomed with small comment explaining on this. That should cover unintentional change of the parent class in the future. WDYT?

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

I think it's a great idea to prevent someone accidentally refactoring it and not realising it was part of the original specs :)

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

It might be pedantic to do all the specs, but even just a spec like, ensuring that the class is a subclass of RangeError could be sufficient.

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

I thought about this a bit more, the only compatibility issue that I can think of would be systems like Honeybadger (or other APMs) which do error reporting, it would mean the class would change and historical data might not align up.. but not sure if I personally care about that much. That being said, it is a user visible change.

Personally I understand and agree with the motiviations of this change, but compatibility needs to be considered carefully, it's not always obvious how it breaks things and people doing minor or patch updates don't necessarily expect it. I've definitely been bitten by stuff like this before in production. Considering how many billions or trillions of requests are handled by Rack daily, the blast radius is pretty big.

@simi
Copy link
Contributor Author

simi commented Apr 6, 2022

@ioquatix currently default Rails app is vulnerable to 500 error (crashing the app on uncaught exception) which could be considered attack vector. Having this custom exception, it would be possible to craft patch to Rails to prevent this and gracefully fail. That's the reason for this backport. Currently it is not possible to release from main branch and update Rails dependency to Rack 3. There is no other option than this (at least I wasn't able to find out any).

A little confused error reporting is not big deal in my eyes, maybe even it is clever enough to group those errors together. No error is going to be hidden, it can just re-appear under different name.

@simi
Copy link
Contributor Author

simi commented Apr 6, 2022

Btw. I have explained all this info to Rafael (indirectly, thru Shopify folks) and that is (probably) the reason to move this forward as soon as possible.

@ioquatix
Copy link
Member

ioquatix commented Apr 6, 2022

Thanks for that information. I didn't know there was a security component to this. I think the take away here is that a little bit more communication would have been helpful here, the original description doesn't give enough context. For reference, here is the original PR: #1837. Might I suggest in the future you start by creating an issue and then link all the relevant PRs.

The bar for security fixes is certainly lower in terms of compatibility but it still needs to be considered carefully. I don't personally have a stake in this, but my expectation is that @tenderlove probably needs to review this change before we make any release. I would also like to hear input from @jeremyevans since he has a keen sense for compatibility issues.

Like I said earlier, I personally support this PR, but that doesn't mean the bar doesn't need to be met, in fact my approval means very little in this particular space as I think other maintainers are more sensitive to the issues here :)

@jeremyevans
Copy link
Contributor

Replacing an exception class with a subclass of the exception class is generally considered a backwards compatible change, as all rescue clauses will still match. Anything it breaks pretty much deserves to be broken.

I don't consider this a security issue, though I'm sure it is annoying to receive bug reports for 500 errors instead of just reporting 4xx errors to the client. That said, I'm fine with the backport to Rack 2.2.

pgwillia added a commit to ualbertalib/builder_deferred_tagging that referenced this pull request Sep 27, 2022
Bumps [rack](https://github.com/rack/rack) from 2.2.2 to 2.2.4.

Changelog
## [2.2.4] - 2022-06-30

- Better support for lower case headers in `Rack::ETag` middleware. ([#1919](rack/rack#1919), [@ioquatix](https://github.com/ioquatix))
- Use custom exception on params too deep error. ([#1838](rack/rack#1838), [@simi](https://github.com/simi))

## [2.2.3.1] - 2022-05-27

- [CVE-2022-30123] Fix shell escaping issue in Common Logger
- [CVE-2022-30122] Restrict parsing of broken MIME attachments

## [2.2.3] - 2020-06-15

### Security

- [[CVE-2020-8184](https://nvd.nist.gov/vuln/detail/CVE-2020-8184)] Do not allow percent-encoded cookie name to override existing cookie names. BREAKING CHANGE: Accessing cookie names that require URL encoding with decoded name no longer works. ([@fletchto99](https://github.com/fletchto99))
pgwillia added a commit to ualbertalib/builder_deferred_tagging that referenced this pull request Sep 27, 2022
Bumps [rack](https://github.com/rack/rack) from 2.2.2 to 2.2.4.

Changelog
## [2.2.4] - 2022-06-30

- Better support for lower case headers in `Rack::ETag` middleware. ([#1919](rack/rack#1919), [@ioquatix](https://github.com/ioquatix))
- Use custom exception on params too deep error. ([#1838](rack/rack#1838), [@simi](https://github.com/simi))

## [2.2.3.1] - 2022-05-27

- [CVE-2022-30123] Fix shell escaping issue in Common Logger
- [CVE-2022-30122] Restrict parsing of broken MIME attachments

## [2.2.3] - 2020-06-15

### Security

- [[CVE-2020-8184](https://nvd.nist.gov/vuln/detail/CVE-2020-8184)] Do not allow percent-encoded cookie name to override existing cookie names. BREAKING CHANGE: Accessing cookie names that require URL encoding with decoded name no longer works. ([@fletchto99](https://github.com/fletchto99))
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.

4 participants