Skip to content

E2e updated#307

Merged
leeN merged 26 commits into
SAP:mainfrom
leeN:e2e-uptodate
Jun 18, 2025
Merged

E2e updated#307
leeN merged 26 commits into
SAP:mainfrom
leeN:e2e-uptodate

Conversation

@leeN

@leeN leeN commented Jun 10, 2025

Copy link
Copy Markdown
Collaborator

Working on a rebased version of end-to-end tainting.

@leeN leeN requested a review from tmbrbr June 10, 2025 20:08
@leeN leeN self-assigned this Jun 10, 2025
Comment thread dom/script/ScriptLoadHandler.cpp Outdated
Comment thread js/loader/LoadedScript.cpp Outdated

@tmbrbr tmbrbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are still some post merge comments in the code.

@leeN leeN marked this pull request as draft June 11, 2025 06:49
@leeN

leeN commented Jun 11, 2025

Copy link
Copy Markdown
Collaborator Author

Oh, sorry, there is some work to do still.

@leeN

leeN commented Jun 12, 2025

Copy link
Copy Markdown
Collaborator Author

Tainting through the JS Parser seems to work (see the mochitest), however, transferring taints from the server does not (yet?).

Originally, this is done here, with mPipe having the type nsCOMPtr<nsIPipe>. This was possible due to changes to the nsIPipe interface. Back then, nsPipe did implement nsIPipe, i.e., here. The nsIPipe code has changed since, such that nsPipe no longer implements said interface. Instead we have an nsPipeHolder class that implements the nsIPipe interface, but only references the two end of the pipe.

@leeN leeN added the enhancement New feature or request label Jun 12, 2025
As we can not get a direct reference to the pipe anymore, this commit adds an workaround.
We can now mark inputstreams as taintable, i.e., they support the `SetTaint method`.
As the input stream can reach back into the pipe, it can reuse the old taint propagation machinery as before.

This lacks meaningful testing, as mochitests can't capture all that well that a piece of HTML from the server is tainted.
When enabling nsHTTP logging, we can see the taint getting passed along however.
@leeN

leeN commented Jun 15, 2025

Copy link
Copy Markdown
Collaborator Author

Sooo, I think I got a workaround in place now. This adds another marker interface for streams that allow to set taints and the input stream can reach back into the nsPipe without having to expose it further.

@leeN

leeN commented Jun 15, 2025

Copy link
Copy Markdown
Collaborator Author

The tests don't quite work as exptected, but you can see the taint getting returned from the server and passed along with:

MOZ_LOG=nsHttp:5 MOZ_UPLOAD_DIR=/tmp MOZ_HEADLESS=1 xvfb-run -- ./mach -v mochitest --headless taint/test/mochitest/test_end2end.html

@leeN

leeN commented Jun 15, 2025

Copy link
Copy Markdown
Collaborator Author

oh, it seems to work (to some degree). If I set up a local server and transmit taints, the .textContent of divs is tainted at least. Nice :)

@leeN

leeN commented Jun 16, 2025

Copy link
Copy Markdown
Collaborator Author

All windows builds are failing for this branch due to automatically enabling debugging flags, will look into that later today.

@tmbrbr

tmbrbr commented Jun 16, 2025

Copy link
Copy Markdown
Contributor

All windows builds are failing for this branch due to automatically enabling debugging flags, will look into that later today.

Do we need the DEBUG flags explicitly for end-2-end tainting, or is this enabled just during development?

@leeN

leeN commented Jun 16, 2025

Copy link
Copy Markdown
Collaborator Author

This is just for development, so I'll disable them again.

Alternatively, we could consider moving that into a build system option similar to taintspew i think?

Comment thread dom/html/HTMLTextAreaElement.cpp
@leeN

leeN commented Jun 16, 2025

Copy link
Copy Markdown
Collaborator Author

I think the textarea aspect is the only open point currently. I'd lean on disabling it, as I'm unsure of the rationale. Maybe disabling it via the preferences is the way to go, thinking about it.

The inline script sink will be a separate PR, as it breaks some tests at the moment, and I would prefer to look into that separately over the coming weeks.
It's mostly generating taint report events where the test does not expect them, so nothing major, but leaving it disabled might be the sane option atm.

@leeN leeN marked this pull request as ready for review June 16, 2025 21:07
@tmbrbr

tmbrbr commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Note that this will supersede #112

@tmbrbr tmbrbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are a few cases where we create StringTaint objects directly, which leak memory when destroyed. I think these should be changed to SafeStringTaints (which deletes the TaintRanges).

Comment thread dom/script/ScriptLoadHandler.cpp Outdated
Comment thread dom/script/ScriptLoadHandler.cpp Outdated
Comment thread netwerk/base/nsNetUtil.cpp Outdated

@tmbrbr tmbrbr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, looks great!

@leeN leeN merged commit d17e86f into SAP:main Jun 18, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants