You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, +1 for this request. When ferrum is used to interact with untrusted user input (ie screenshot a website), --disable-web-security can lead to terrible side effects, like reading local files on the server.
ie, ferrum was tasked with taking a screenshot of https://site/page.html with the following contents:
<iframe src="file:///etc/passwd"></iframe>, then the contents of the file will be shown in the screenshot.
This should not be made possible for obvious reasons.
I ran the Ferrum and Cuprite suites against Chrome 155 with --disable-web-security removed from the defaults. Here's what changes:
Ferrum: 625 examples, 1 failure.
Frame#frame_element returns nil for cross-origin iframes. It reads window.frameElement, which the same-origin policy hides from a cross-origin child. Same-origin iframes keep working. The spec only fails because its fixture loads the page from 127.0.0.1 and the iframes from localhost, which are different origins.
Cuprite: 1844 examples, 1 failure.
current_url called inside a cross-origin iframe (within_frame) raises SecurityError: Blocked a frame ... from accessing a cross-origin frame. Frame#current_url reads window.top.location.href from inside the frame, and a cross-origin child isn't allowed to read that. It could be evaluated in the main frame's context instead and stay a JS call.
Cuprite's click checks (mouseEventTest, isObscured) also use window.frameElement. Inside a cross-origin iframe the frame offset would become 0. The suite doesn't cover this.
Plan
Remove disable-web-security from Ferrum's default flags, so tools that load untrusted pages (screenshots, scraping) keep the same-origin policy. That closes the file:// iframe problem reported above.
Add the flag to Cuprite's default flags, so test suites keep their current behavior, and release both together.
Document that frame_element works only for same-origin iframes, and note the change in the CHANGELOG. Anyone who needs the old behavior can pass browser_options: { "disable-web-security" => nil }.
Activity
francisbeaudoin commentedon Mar 10, 2025
Hey @route 👋 I'm wondering if we could get this changed in the defaults?
route commentedon Mar 11, 2025
I think it's useful for Cuprite and tests, so we could move it there and remove from Ferrum
ldionmarcil commentedon Apr 16, 2025
Hi, +1 for this request. When ferrum is used to interact with untrusted user input (ie screenshot a website),
--disable-web-securitycan lead to terrible side effects, like reading local files on the server.ie, ferrum was tasked with taking a screenshot of
https://site/page.htmlwith the following contents:<iframe src="file:///etc/passwd"></iframe>, then the contents of the file will be shown in the screenshot.This should not be made possible for obvious reasons.
route commentedon Oct 15, 2026
I ran the Ferrum and Cuprite suites against Chrome 155 with
--disable-web-securityremoved from the defaults. Here's what changes:Ferrum: 625 examples, 1 failure.
Frame#frame_elementreturnsnilfor cross-origin iframes. It readswindow.frameElement, which the same-origin policy hides from a cross-origin child. Same-origin iframes keep working. The spec only fails because its fixture loads the page from127.0.0.1and the iframes fromlocalhost, which are different origins.Cuprite: 1844 examples, 1 failure.
current_urlcalled inside a cross-origin iframe (within_frame) raisesSecurityError: Blocked a frame ... from accessing a cross-origin frame.Frame#current_urlreadswindow.top.location.hreffrom inside the frame, and a cross-origin child isn't allowed to read that. It could be evaluated in the main frame's context instead and stay a JS call.mouseEventTest,isObscured) also usewindow.frameElement. Inside a cross-origin iframe the frame offset would become 0. The suite doesn't cover this.Plan
disable-web-securityfrom Ferrum's default flags, so tools that load untrusted pages (screenshots, scraping) keep the same-origin policy. That closes thefile://iframe problem reported above.frame_elementworks only for same-origin iframes, and note the change in the CHANGELOG. Anyone who needs the old behavior can passbrowser_options: { "disable-web-security" => nil }.fix(driver): add --disable-web-security to the browser options (#342)
chore(deps): bump the bundler group with 8 updates (#1436)
Bump cuprite from 0.18 to 0.19 (DFE-Digital#3704)
fix(browser): drop --disable-web-security from default Chrome flags (r…
Bump the general-gems group with 6 updates (#9404)