Closed Bug 1652707 Opened 5 years ago Closed 4 years ago

nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith

Categories

(Core :: DOM: Security, enhancement, P3)

enhancement

Tracking

()

RESOLVED WONTFIX

People

(Reporter: freddy, Assigned: holaszyd1)

References

Details

(Keywords: good-first-bug, Whiteboard: [domsecurity-backlog1])

Attachments

(1 obsolete file)

When going through the loop of allowlist entries, we use a StringBeginsWith check to ensure we do not sumble over script locations like resource://gre/modules/workers/require.js line 138 > Function.

Instead, we might be able to use

nsCOMPtr<nsIStackFrame> location = GetCurrentJSStack(1)
JSContext* cx = nsContentUtils::GetCurrentJSContext();
location->GetFilename(cx, caller);

and compare those instead

Whiteboard: [domsecurity-backlog1]

Hi please i would like to work on this

Assignee: nobody → holaszyd1
Status: NEW → ASSIGNED
Attachment #9249254 - Attachment description: Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith. r?freddyb → Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith.. r?freddyb
Attachment #9249254 - Attachment description: Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith.. r?freddyb → Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith... r?freddyb
Attachment #9249254 - Attachment description: Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith... r?freddyb → Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith.... r?freddyb
Attachment #9249254 - Attachment description: Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith.... r?freddyb → Bug 1652707- nsContentSecurityUtils::IsEvalAllowed should use filename comparison instead of StringBeginsWith. r?tjr

It turns out we can't fix this. The prefix-based comparison is needed because an exact match will need to include the line number of the offending call; and hardcoding that is too brittle. Performing a regex match (on the hot path) would be prohibitively expensive and wouldn't work off-main-thread. Emulating a regex match would be possible, but complicated and doesn't seem worth it for the versatility we have here.

Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
Attachment #9249254 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: