Skip to content

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Aug 12, 2021

This also adds some missing UriInfo taint propagators I noticed while doing this.

@smowton smowton requested a review from a team as a code owner August 12, 2021 13:54
@github-actions github-actions bot added the Java label Aug 12, 2021
@github-actions
Copy link
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged. The following differences were found:

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java extensions,"``javax.*``, ``jakarta.*``",22,540,27,,,,,1,1,2
+    Java extensions,"``javax.*``, ``jakarta.*``",36,546,27,,,,,1,1,2
-    Totals,,84,2711,398,13,6,6,107,33,1,66
+    Totals,,98,2717,398,13,6,6,107,33,1,66
  • Changes to framework-coverage-java.csv:
+ jakarta.ws.rs.container,,7,,,,,,,,,,,,,,,,,,,7,,
- jakarta.ws.rs.core,2,,143,,,,,,,,,,,,,,,2,,,,88,55
+ jakarta.ws.rs.core,2,,146,,,,,,,,,,,,,,,2,,,,91,55
+ javax.ws.rs.container,,7,,,,,,,,,,,,,,,,,,,7,,
- javax.ws.rs.core,3,,143,,,,1,,,,,,,,,,,2,,,,88,55
+ javax.ws.rs.core,3,,146,,,,1,,,,,,,,,,,2,,,,91,55

bmuskalla
bmuskalla previously approved these changes Aug 17, 2021
"javax.ws.rs.core;UriInfo;true;getPathParameters;;;Argument[-1];ReturnValue;taint",
"javax.ws.rs.core;UriInfo;true;getPathSegments;;;Argument[-1];ReturnValue;taint",
"javax.ws.rs.core;UriInfo;true;getQueryParameters;;;Argument[-1];ReturnValue;taint",
"javax.ws.rs.core;UriInfo;true;getRequestUri;;;Argument[-1];ReturnValue;taint",
"javax.ws.rs.core;UriInfo;true;getRequestUriBuilder;;;Argument[-1];ReturnValue;taint",
"jakarta.ws.rs.core;UriInfo;true;getAbsolutePath;;;Argument[-1];ReturnValue;taint",
"jakarta.ws.rs.core;UriInfo;true;getAbsolutePathBuilder;;;Argument[-1];ReturnValue;taint",
"jakarta.ws.rs.core;UriInfo;true;getPath;;;Argument[-1];ReturnValue;taint",
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if calls to relativize should mark it's return value as tainted as it may include path elements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

private class ContainerRequestContextModel extends SourceModelCsv {
override predicate row(string s) {
s =
["javax", "jakarta"] + ".ws.rs.container;ContainerRequestContext;true;" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat :)

[
"getAcceptableLanguages", "getAcceptableMediaTypes", "getCookies", "getEntityStream",
"getHeaders", "getHeaderString", "getUriInfo"
] + ";;;ReturnValue;remote"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how feasible that is right now but I wonder if the context should also be treated like a Map to ensure the setProperty and getProperty calls propagate taint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In common with my approach to JSON-related libs I didn't bother to distinguish them because the use case is deserialization -> read or write -> serialization, where we only care about a single monolithic concept of taint, as opposed to map-writes followed by map-reads as with a general-purpose data structure. If we catch people actually using these like general-purpose data structures in the wild though, then we should do the extra work and increase the fidelity of our modelling as you suggest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally agree. In this particular case, I thought that the context properties are actually the designated way to pass data among the filters and to the content producers (see also https://abhirockzz.wordpress.com/2016/03/16/sharing-data-between-jax-rs-filters/ ). But this may be better modelled as part of a query than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, interesting, hadn't seen that done. To support that case we would need to model the control-flow from one filter to another, since that is implemented in opaque framework code.

@github-actions
Copy link
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged. The following differences were found:

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java extensions,"``javax.*``, ``jakarta.*``",22,540,27,,,,,1,1,2
+    Java extensions,"``javax.*``, ``jakarta.*``",36,552,27,,,,,1,1,2
-    Totals,,84,2711,398,13,6,6,107,33,1,66
+    Totals,,98,2723,398,13,6,6,107,33,1,66
  • Changes to framework-coverage-java.csv:
+ jakarta.ws.rs.container,,7,,,,,,,,,,,,,,,,,,,7,,
- jakarta.ws.rs.core,2,,143,,,,,,,,,,,,,,,2,,,,88,55
+ jakarta.ws.rs.core,2,,149,,,,,,,,,,,,,,,2,,,,94,55
+ javax.ws.rs.container,,7,,,,,,,,,,,,,,,,,,,7,,
- javax.ws.rs.core,3,,143,,,,1,,,,,,,,,,,2,,,,88,55
+ javax.ws.rs.core,3,,149,,,,1,,,,,,,,,,,2,,,,94,55

Copy link
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

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

Added a couple of inline comments, otherwise LGTM.

@github-actions
Copy link
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged. The following differences were found:

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java extensions,"``javax.*``, ``jakarta.*``",22,540,27,,,,,1,1,2
+    Java extensions,"``javax.*``, ``jakarta.*``",40,552,27,,,,,1,1,2
-    Totals,,84,2711,398,13,6,6,107,33,1,66
+    Totals,,102,2723,398,13,6,6,107,33,1,66
  • Changes to framework-coverage-java.csv:
+ jakarta.ws.rs.container,,9,,,,,,,,,,,,,,,,,,,9,,
- jakarta.ws.rs.core,2,,143,,,,,,,,,,,,,,,2,,,,88,55
+ jakarta.ws.rs.core,2,,149,,,,,,,,,,,,,,,2,,,,94,55
+ javax.ws.rs.container,,9,,,,,,,,,,,,,,,,,,,9,,
- javax.ws.rs.core,3,,143,,,,1,,,,,,,,,,,2,,,,88,55
+ javax.ws.rs.core,3,,149,,,,1,,,,,,,,,,,2,,,,94,55

@smowton smowton force-pushed the smowton/feature/jax-rs-request-filters branch from 0e9ab52 to 95046b9 Compare September 10, 2021 15:36
s =
["javax", "jakarta"] + ".ws.rs.container;ContainerRequestContext;true;" +
[
"getAcceptableLanguages", "getAcceptableMediaTypes", "getCookies", "getEntityStream",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can Locale contain arbitrary taint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it turns out yes -- the docs for Locale specify what the parameters should be (e.g. language - An ISO 639 alpha-2 or alpha-3 language code), but it doesn't actually check that that's the case. I forget where exactly but I think @atorralba wrote a little test case recently showing attack code from an HTTP Accept header making it through unaltered to Locale.toString.

Copy link
Contributor

@atorralba atorralba Sep 13, 2021

Choose a reason for hiding this comment

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

@smowton smowton merged commit 68ed325 into github:main Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants