Skip to content

Make allowNetworking testable and throw in AVM2 navigateToURL - #25102

Open
evilpie wants to merge 3 commits into
ruffle-rs:masterfrom
evilpie:allowNetworking
Open

evilpie wants to merge 3 commits into
ruffle-rs:masterfrom
evilpie:allowNetworking

Conversation

@evilpie

@evilpie evilpie commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part of #25100 and #3044.

This is the first step towards more correctly implementing the allowNetworking setting (Restricting networking APIs) that can be used with <object> or <embed> tags. This is mostly just some preliminary architectural work. As a proof of concept I implemented throwing in AVM2's navigateToURL. I think next we should probably expose this to the desktop app.

Afterwards of course all the APIs listed in the Adobe documentation need to be restricted.

Testing

This feature is only available when running the Flash Player inside a browser, so this isn't directly testable with something like flashplayerdebugger. I did test this using https://hub.docker.com/r/jchprj/play-adobe-flash-after-eol.

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

@@ -0,0 +1,3 @@
SecurityError: Error #2146: Security sandbox violation: file:///test.swf cannot call navigateToURL because the HTML/container parameter allowNetworking has the value none.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How did you get these outputs? I.e. how to configure the standalone player to change the value of "allow networking"?

We do have an executor for Flash Player, so ideally we would configure the player there when the setting is enabled.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That is not possible, as mentioned in the description.

Do we have a runner for Flash inside the browser?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't, but we could add a web runner.

In order to make it clearer from the tests perspective I would do the following changes:

  1. load the SWF via http and not files (we have the localhost directory, but not sure if we can load the root SWF this way),
  2. add a second test.toml property that specifies which version of flash should be used to run this test in (e.g. `flashplayer_edition = "sa"/"web"),
  3. filter out web tests for now in the executor.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Of course log_fetch is problematic here as well, but that's preexisting. If you can assert in a different way that no request was made it would be better (e.g. via event listeners).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To be clear: this is not blocking, a lot of other tests cannot be executed OOTB in flash player as well

@danielhjacobs danielhjacobs added A-avm2 Area: AVM2 (ActionScript 3) T-compat Type: Compatibility with Flash Player labels Nov 5, 2026
evazion referenced this pull request in danbooru/danbooru Nov 5, 2026
Ruffle gave Flash files script access to the page by default. When loading a URL, it sets `allowScriptAccess`
to `samedomain`, which is true when the SWF is served from the site's own domain. This let any Flash post call
`ExternalInterface` to run JavaScript as the viewer and hijack their account. It also allowed `navigateToURL`
and unrestricted network access.

Fix it by disabling script access, networking, and URL opening in the Ruffle config, and by running the player
inside an `<iframe sandbox="allow-scripts" srcdoc="...">`. The sandboxed frame has an opaque origin, so even if
Ruffle has a bug, a malicious Flash file can't access the user's cookies, session, or the parent page.

Because the frame's origin is `null`, Ruffle's fetches for the .wasm and .swf files now count as cross-origin. For this reason, the shipped nginx for the prod image now sends `Access-Control-Allow-Origin: *` for .wasm and .swf files only. CDNs serving flash files might need to have their caches purged and/or add this header to these extensions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm2 Area: AVM2 (ActionScript 3) T-compat Type: Compatibility with Flash Player

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants