Skip to content

Add Url to JavascriptBindingEventArgs - #5021

Merged
amaitland merged 1 commit into
masterfrom
enhancement/addurltoJavascriptBindingEventArgs
Jan 31, 2025
Merged

amaitland merged 1 commit into
masterfrom
enhancement/addurltoJavascriptBindingEventArgs

Conversation

@amaitland

@amaitland amaitland commented Jan 2, 2025 •

Copy link
Copy Markdown
Member

Issue #5001

Summary:

  • Add additional info to event args

Changes:

  • Add url to event args

How Has This Been Tested?
Tests have been updated

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Updated documentation

Checklist:

  • Tested the code(if applicable)
  • Commented my code
  • Changed the documentation(if applicable)
  • New files have a license disclaimer
  • The formatting is consistent with the project (project supports .editorconfig)

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@amaitland
amaitland force-pushed the enhancement/addurltoJavascriptBindingEventArgs branch from acda14f to 0cb2878 Compare January 2, 2025 23:05
@amaitland amaitland changed the title Add Url to JavascriptBinding event args and allow for custom method runner queue Add Url to JavascriptBinding event args Jan 2, 2025
@amaitland

Copy link
Copy Markdown
Member Author

I had originally though about exposing the JS repository and method runner queue for users to customise, reverted this change as I'm not sure that it's wise.

@amaitland amaitland changed the title Add Url to JavascriptBinding event args Add Url to JavascriptBindingEventArgs Jan 2, 2025
@amaitland
amaitland marked this pull request as ready for review January 2, 2025 23:13
@AppVeyorBot

Copy link
Copy Markdown

@petrdrabek

Copy link
Copy Markdown

@amaitland I’ve done a deep dive into the origin restriction security issue, and unfortunately, this approach doesn’t fully resolve the problem.

Here’s the core issue: in the JavascriptObjectRepository_ResolveObject(object sender, CefSharp.Event.JavascriptBindingEventArgs e) method, it’s not possible to prevent object registration in JavaScript when CefSharp.BindObjectAsync() is called.

For example:

  1. A browser instance has a main frame and several iFrames.
  2. The main frame, with an allowed origin, successfully calls CefSharp.BindObjectAsync(), and objects are registered.
  3. None of the iFrames can access these objects, which is correct.
  4. However, if an iFrame with a disallowed origin calls CefSharp.BindObjectAsync(), the JavascriptObjectRepository_ResolveObject method is triggered. Since the objects are already registered in the JavascriptObjectRepository (i.e., IsBound(objectName) returns true), simply returning from the method gives the iFrame access to these objects. Currently, the only option to prevent this is to call javascriptObjectRepository.UnRegisterAll(), but this also removes access for the main frame, which is not ideal:
//  
// Summary:  
//     Unregister all the currently bound objects from the repository.  
//     If you unregister an object that is currently bound in JavaScript,  
//     method/property calls will fail.  
void UnRegisterAll();  

This limitation makes it difficult to manage object access based on origin securely.

@amaitland

Copy link
Copy Markdown
Member Author

I’ve done a deep dive into the origin restriction security issue, and unfortunately, this approach doesn’t fully resolve the problem.

Nor is it expected to. This is just a piece of the puzzle.

Additional code changes would be required as per my comment at #5001 (comment)

@amaitland amaitland added this to the 132.3.x milestone Jan 17, 2025
@amaitland amaitland modified the milestone: 132.3.x Jan 30, 2025
@amaitland
amaitland merged commit 3a749c0 into master Jan 31, 2025
@amaitland
amaitland deleted the enhancement/addurltoJavascriptBindingEventArgs branch January 31, 2025 20:47
amaitland added a commit that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants