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

Remove URN support #1930

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

rousskov
Copy link
Contributor

@rousskov rousskov commented Oct 31, 2024

Squid URN resolution code has been neglected for a very long time and
caused multiple security vulnerabilities. Its existence complicates
planned StoreClient API refactoring. URN resolution feature is rarely
used (if at all). If Squid handling of unknown (to Squid) URI schemes is
enhanced, a similar feature can be implemented externally, using
url_rewrite_program helpers or adaptation services.

Squid now treats URN as any unknown (to Squid) URI scheme, typically
responding with an HTTP 400 (Bad Request) ERR_INVALID_URL.

Prior to these changes, Squid did not forward HTTP requests with URN
scheme targets to cache_peers either. Instead, Squid rewrote request
targets into URLs with an HTTP scheme (and a /uri-res/N2L? path
prefix; see Historic THTTP RFC 2169) and forwarded those adapted
requests. That hard-coded adaptation and forwarding are now gone.

kinkie
kinkie previously approved these changes Oct 31, 2024
Copy link
Contributor

@kinkie kinkie left a comment

Choose a reason for hiding this comment

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

YES!

Copy link
Contributor Author

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

This minimal PR implements URN support removal as I requested earlier. It does not add support for forwarding requests with URN scheme (and other unsupported schemes) to cache_peers. I am not sure there is enough need for such forwarding, but that should be settled separately if somebody actually decides to work on adding that new feature.

@@ -48,6 +48,5 @@ ERROR_TEMPLATES = \
templates/ERR_TOO_BIG \
templates/ERR_UNSUP_HTTPVERSION \
templates/ERR_UNSUP_REQ \
templates/ERR_URN_RESOLVE \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR does not update PO/POT files based on an earlier recommendation. If those files should be updated to reflect ERR_URN_RESOLVE removal, please let me know, and we will update them (you can even preview most of those changes in earlier branch commit c00c79a that was later reverted).

Copy link
Contributor

Choose a reason for hiding this comment

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

These templates are used to generate the "langpack" releases which get installed for use by much older versions of Squid. The template file needs to be retained until no supported version of Squid tries to load it on startup.

This is also why the ERR_ESI remains.

Copy link
Contributor

Choose a reason for hiding this comment

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

The template file needs to be retained

Restored at 0f42fbd.

@rousskov rousskov added the S-waiting-for-more-reviewers needs a reviewer and/or a second opinion label Oct 31, 2024
Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

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

Some major flaws to get you started.

Comment on lines 132 to 133
<p>If necessary, a similar feature can be implemented externally, using
url_rewrite_program helpers or adaptation services.
Copy link
Contributor

Choose a reason for hiding this comment

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

That would be a bug. You have removed the ability for Squid to correctly:
a) parse any request-target with "urn:" scheme, and
b) send a valid URN anywhere (including helpers, ICAP, eCAP, and even cache.log - receive unknown:// at most)

A squid lacking "foo:" support should reject all "foo:" URLs on initial parse/validate. Failure to do that re-opens one of those security vulnerabilities I closed off by fixing the URN NID validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have removed the ability for Squid to ... send a valid URN anywhere (including helpers, ICAP, eCAP...)

Agreed. I have adjusted PR description and release notes (commit 14914f4) to precondition external support on enhancing Squid to handle unknown (to Squid) URI schemes (which should not be limited to URN scheme, of course). Fortunately, we do not need to debate the details of that hypothetical enhancement -- folks implementing it should initiate that debate outside this PR.

@@ -48,6 +48,5 @@ ERROR_TEMPLATES = \
templates/ERR_TOO_BIG \
templates/ERR_UNSUP_HTTPVERSION \
templates/ERR_UNSUP_REQ \
templates/ERR_URN_RESOLVE \
Copy link
Contributor

Choose a reason for hiding this comment

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

These templates are used to generate the "langpack" releases which get installed for use by much older versions of Squid. The template file needs to be retained until no supported version of Squid tries to load it on startup.

This is also why the ERR_ESI remains.

Comment on lines 129 to 130
<p>Squid URN resolution code has been neglected for a very long time and caused
multiple security vulnerabilities. This feature was rarely used (if at all).
Copy link
Contributor

Choose a reason for hiding this comment

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

Come on be honest. All attempts to update the code were vetoed by you. Otherwise this code would very much have been updated by at least four authors in the past 10 years.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Come on be honest. All attempts to update the code were vetoed by you. Otherwise this code would very much have been updated by at least four authors in the past 10 years.

I hope that any vetoes were correct, but this discussion and implications of dishonesty feel out of scope: PR text describes code state. It does not speculate about the reasons that led to that code state.

@@ -56,7 +56,6 @@ Adaptation::Ecap::Host::Host()
libecap::protocolHttps.assignHostId(AnyP::PROTO_HTTPS);
libecap::protocolFtp.assignHostId(AnyP::PROTO_FTP);
libecap::protocolWais.assignHostId(AnyP::PROTO_WAIS);
libecap::protocolUrn.assignHostId(AnyP::PROTO_URN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thus rendering eCAP unable to meet the release notes claimed capability of performing Trivial-HTTP Resolver gateway.
("AnyP::PROTO_UNKNOWN" are passed as static string "unknown", not as the received scheme image)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Host application IDs being configured by this code are an optimization that speeds up string comparison for common cases. eCAP code should function correctly without that optimization. If it does not, it is an out-of-scope bug (in eCAP adapter or host application code).

absolute_.append(":", 1);
absolute_.append("//", 2);
const bool allowUserInfo = getScheme() == AnyP::PROTO_FTP ||
getScheme() == AnyP::PROTO_UNKNOWN;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to exclude URI with image() of "urn:" (which is now part of AnyP::PROTO_UNKNOWN) or we open a security vulnerability for sensitive data exfiltration.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, these changes are what render ICAP and helpers unable to meet the release notes claimed capability of performing Trivial-HTTP Resolver gateway.

Copy link
Contributor Author

@rousskov rousskov Nov 26, 2024

Choose a reason for hiding this comment

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

This needs to exclude URI with image() of "urn:" (which is now part of AnyP::PROTO_UNKNOWN) or we open a security vulnerability for sensitive data exfiltration.

PR code treats all unknown (to Squid) URI schemes the same. This code had received unknown non-URN schemes prior to PR changes. Thus, the "we open a vulnerability" assertion is false: Either that vulnerability existed before these changes, or these changes do not open it.

Also, these changes are what render ICAP and helpers unable to meet the release notes claimed capability of performing Trivial-HTTP Resolver gateway.

That problem was flagged and addressed in another change request. If necessary, let's continue this part of the discussion there.

@kinkie kinkie added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-more-reviewers needs a reviewer and/or a second opinion labels Nov 2, 2024
Also described how URNs are treated now.
Copy link
Contributor Author

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

I believe all change requests have been addressed. Please re-review.

Comment on lines 129 to 130
<p>Squid URN resolution code has been neglected for a very long time and caused
multiple security vulnerabilities. This feature was rarely used (if at all).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Come on be honest. All attempts to update the code were vetoed by you. Otherwise this code would very much have been updated by at least four authors in the past 10 years.

I hope that any vetoes were correct, but this discussion and implications of dishonesty feel out of scope: PR text describes code state. It does not speculate about the reasons that led to that code state.

Comment on lines 132 to 133
<p>If necessary, a similar feature can be implemented externally, using
url_rewrite_program helpers or adaptation services.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You have removed the ability for Squid to ... send a valid URN anywhere (including helpers, ICAP, eCAP...)

Agreed. I have adjusted PR description and release notes (commit 14914f4) to precondition external support on enhancing Squid to handle unknown (to Squid) URI schemes (which should not be limited to URN scheme, of course). Fortunately, we do not need to debate the details of that hypothetical enhancement -- folks implementing it should initiate that debate outside this PR.

@@ -56,7 +56,6 @@ Adaptation::Ecap::Host::Host()
libecap::protocolHttps.assignHostId(AnyP::PROTO_HTTPS);
libecap::protocolFtp.assignHostId(AnyP::PROTO_FTP);
libecap::protocolWais.assignHostId(AnyP::PROTO_WAIS);
libecap::protocolUrn.assignHostId(AnyP::PROTO_URN);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Host application IDs being configured by this code are an optimization that speeds up string comparison for common cases. eCAP code should function correctly without that optimization. If it does not, it is an out-of-scope bug (in eCAP adapter or host application code).

absolute_.append(":", 1);
absolute_.append("//", 2);
const bool allowUserInfo = getScheme() == AnyP::PROTO_FTP ||
getScheme() == AnyP::PROTO_UNKNOWN;
Copy link
Contributor Author

@rousskov rousskov Nov 26, 2024

Choose a reason for hiding this comment

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

This needs to exclude URI with image() of "urn:" (which is now part of AnyP::PROTO_UNKNOWN) or we open a security vulnerability for sensitive data exfiltration.

PR code treats all unknown (to Squid) URI schemes the same. This code had received unknown non-URN schemes prior to PR changes. Thus, the "we open a vulnerability" assertion is false: Either that vulnerability existed before these changes, or these changes do not open it.

Also, these changes are what render ICAP and helpers unable to meet the release notes claimed capability of performing Trivial-HTTP Resolver gateway.

That problem was flagged and addressed in another change request. If necessary, let's continue this part of the discussion there.

@rousskov rousskov requested a review from yadij November 26, 2024 14:39
@rousskov rousskov added S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box and removed S-waiting-for-author author action is expected (and usually required) labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants