Giter Site home page Giter Site logo

pes10k / web-api-manager Goto Github PK

View Code? Open in Web Editor NEW
101.0 9.0 17.0 1.41 MB

(Unmaintained) WebExtension based browser extension to manage and block untrusted parts of the Web API.

License: GNU General Public License v3.0

JavaScript 89.61% CSS 0.14% HTML 10.25%

web-api-manager's Introduction

Web API Manager

This project is not currently maintained. I no longer have the time to keep it supported. I would welcome a co-maintainer to work with though, if someone might be interested. If so, please contact me over email.

Running the Extension

Download built versions of the extension from each browsers' extension stores:

By default, this extension does not make any changes. No aspects of the Web API are affected until you start creating custom rule sets, or modifying what Web API standards sites have access to by default. You can start creating these rules through the site's configuration pane.

You can find some suggested page configurations in the Wiki.

Overview

This extension allows users to selectively allow different hosts on the web to have access to different types of browser functionality. Doing so allows security and privacy sensitive web users to limit the attack surface presented to websites, and to limit websites to the functionality they actually need to carry out user-serving purposes.

Background

Web browsers gain staggering numbers of new features, without their users knowing what new functionality is being pushed into their trusted base. While some of this functionality is broadly useful for things commonly thought of as "web" related, a large amount of it is useful in only rare situations, if ever. Examples of this rarely-needed functionality includes the low level audio synthesis capabilities of the Web Audio API, the low level graphics capabilities of WebGL, or the light sensing capabilities of the Ambient Light Sensor API. Such complex-but-rarely-used functionality has been often used in attacks on the security and privacy of the web.

Other functionality is frequently used by web sites, but for non-user-serving purposes, like fingerprinting anonymous users and tracking them across websites. Examples of such functionality includes parts of the SVG API, parts of the the Canvas Element's functionality, and the Beacon standard, among many others.

This extension helps users stay private and secure online by limiting websites to only the functionality they need, and prevent them from accessing rarely needed and/or privacy violating functionality.

Functionality

The extension currently includes the following functionality:

  • Creation of domain-specific functionality rules, based on host-matching regular expressions.
  • Blocking of functionality across all domains, with a fallback, "default" blocking rule.
  • A novel method of blocking functionality, designed to minimize the effect of removing functionality on existing code that expects that functionality to be in place.
  • A categorization of approximately 1,400 JavaScript methods into 74 different Web API standards (and, where appropriate, sub-standards).
  • User feedback to alert users how many hosts are executing script every time they visit a site, to ease the creating of new rules.

The following functionality is not currently implemented, but is being considered for future inclusion:

  • The ability to subscribe to blocking rule sets created by trusted third parties, similar to the EasyList / AdBlockPlus model of rule subscriptions.
  • Blocking property accesses on non-global structures through an additional level of interposition on runtime created objects.
  • Adding new Web API standards into the code base.
  • Extend blocking to properties and events (currently only functions and methods are interposed on).

Contributing

Pull requests and contributions of all kinds are greatly appreciated. One thing that would be extremely helpful is help compiling information about new browser standards. The process is not too tricky, and is documented at docs/ADDING_STANDARDS.md.

And in general, please feel free to reach out, either through the issue queue or through email ([email protected]).

Building

You can build the extension with the following steps:

npm install
npm run bundle

# You'll then have a zip'ed up version of the extension at `dist/webapi_manager.zip`

Testing and Development

There is a Mocha and Selenium based test suite in place now. To run it you'll need to provide the test suite with some social networking credentials (to make check for previous regressions related to cookies and logging into sites).

To run the tests, give the following a try:

# install the development libraries
npm install

# copy the skeleton config file to where the test scripts expect it to be.
cp test.config.example.js test.config.js

# edit the new test config file to add github and google account credentials
vim test.config.js

# Run the test suite
npm test

# Or, if you want to watch the tests run...
npm run test:watch

Background

This extension is based on research conducted at the BITSLab at the University of Illinois at Chicago. Further information on the measurements and techniques used in this extension can be found in the following papers.

web-api-manager's People

Contributors

bengansukh avatar dependabot[bot] avatar pes10k avatar psnyde2 avatar snyderp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web-api-manager's Issues

Loging improvement suggestion

Can you add additional info by which "Blocked standard" something was blocked.
Otherwise, it is quite hard to find out what needs to be un-checked in the settings to restore functionality.

Thank you
Cheers

Extension can get stuck in an infinite loop

Code like the below can cause an infinite loop

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Testing Infinite Loop Case</title>
    </head>
    <body>
        <div id="example-div">
            <p>A child node</p>
        </div>
        <script>
            // For testing when "Selectors API Level 1" is being blocked.
            const exampleDiv = document.querySelector("example-div");
            let childNode = exampleDiv.childNode;
            let nextSibling;

            // Will be stuck in an infinite loop, as nextSibling will keep
            // returning the blockign proxy.
            while (childNode) {
                nextSibling = childNode.nextSibling;
                exampleDiv.removeChild(childNode);
                childNode = nextSibling;
            }
        </script>
        <script>
            // This will only trigger if the above infinite loop is broken.
            const elementToInsert = document.createElement("div");
            elementToInsert.className = "success-case";
            document.body.appendChild(elementToInsert);
        </script>
    </body>
</html>

aggressive settings modified

To comment on reddit and watch a video on YouTube I had to change a few settings on the aggressive preset. Just putting them out here for reference. You may want a link in the add-on to come to the github page and a link to the wiki if you decide on using it :)

YouTube seemed to need all of these:
uncheck CSSOM View Module
uncheck File API
uncheck Fullscreen API
uncheck HTML: Web Storage
uncheck Media Source Extensions

uncheck Selection API (couldn't comment on reddit)

And I went ahead and checked these two because I don't need them:
check Service Workers
check Vibration API

Add "only" logging mode

Would be handy to have a measurement mode, that logs all the functionality that is used on the page, w/o blocking it

The page isn’t redirecting properly

I have a page that gets this error even if I clear all "blocked standards":

The page isn’t redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.

From log:
[HTTP/1.1 302 Moved Temporarily]

The only way making it work is to disable WAM,

If would like not to reveal URL here.

Trying to block webkitCurrentFullScreenElement throws

    at <anonymous>:73:45
    at Array.reduce (<anonymous>)
    at keyPathToRefPath (<anonymous>:62:29)
    at blockFeatureAtKeyPath (<anonymous>:153:34)
    at Array.forEach (<anonymous>)
    at <anonymous>:192:25
    at <anonymous>:222:6```

Firefox Sync

It would be helpful to sync the settings across browsers.

Does Firefox support File API?

I was looking around and what I've read is Firefox does not support the File API but made their own API called DeviceStorageAPI controlled by about:config pref device.storage.enabled (defaulted to false).

Blog post from 2012 https://hacks.mozilla.org/2012/07/why-no-filesystem-api-in-firefox/

Now, this add-on does cause problems with YouTube if the File API is blocked, so it must be blocking something in Firefox that does indeed follow the File API, though I don't know what the device.storage.enabled pref for their homegrown API does.

Sharing settings

For two or more domains which share the same setup (a non default setup),
I think it would be better to set the rule as follows:

*.abc.net,*.xyz.org,*.foo.com,*.bar.com

That means the "pattern" field needs to be an array of domains.

[
	{
		"pattern":[
			"*.abc.net",
			"*.xyz.org",
			"*.foo.com",
			"*.bar.info"
		],
		
		"standards":[
			"Ambient Light Sensor API",
			"Battery Status API",
			"Beacon",
			......
		]
	}
]
]

Thank you so much for this exceptional extension !

base off of uMatrix?

This can totally be closed but I was wondering -with uMatrix's grid layout, if you decide to adapt a subscription and per-site control, if it would be easier to manage with a different layout.

Esp. When dealing with third party content

Issue with copying to clipboard on keeweb

WebAPI manager v0.9.13
Config: all clear

I use keeweb (self-hosted) as my password manager for some time and I'm having issue with your latest version.

My keeweb is opened in a browser's tab. I copy my credentials from there.

Copy by clicking on the username item = FAIL
Copy by clicking on the password item = FAIL
Copy username using keyboard shortcut (Ctrl+B) = FAIL
Copy password using keyboars shortcut (Ctrl+C) = SUCCESS

The examples at https://clipboardjs.com/ work however. I have to disable this extension to copy my credentials.

Additional CSP Issues

The following CSP keeps the injected script from executing…

default-src https: data: 'unsafe-inline' 'unsafe-eval'; child-src https: data: blob:; connect-src https: data: blob:; font-src https: data:; img-src https: data: blob:; media-src https: data: blob:; object-src https:; script-src https: data: blob: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'; block-all-mixed-content; upgrade-insecure-requests; report-uri https://capture.condenastdigital.com/csp/pitchfork

request an option to notify user with requests per API

It would be nice if, at some point, you could have check boxes beside each API to also pop-up a little notification with an alert that "Battery API was allowed/blocked for example.com."

Something that came up faded away after 2 or 3 seconds. It would kinda give the use an idea of what's popular on sites and I think it could help visualize how they're used without jumping to the console.

Correct text in browser action for "secure" URLs

Some URLs (ex the start page in firefox) don't allow the extension to inject script. This means that the extension can't determine how many origins are on the current page (even though there is only one).

Would be good to correct this text, to just make the "The following origins are execiting code on this page." text less confusing in situations were we can't determine which origins are executing

standards.js word

...\content_scripts\dist\standards.js .. idenitifer .. is that meant to be "identifier" (and calls to it elsewhere?). I know its not a typo, because it's used 74 times

      "info": {
         "name": "XMLHttpRequest",
         "subsection_number": null,
         "subsection_name": null,
         "url": "https://xhr.spec.whatwg.org/",
         "idenitifer": "XMLHttpRequest"
      },

add corresponding preference names

interesting extension - if the developers are not aware, you might also want to look at http-useragent-cleaner which offers some similar functionality - it's legacy and the UI is bad, but maybe there is something to be gained from it's code regarding development of API Manager

i don't know how useful this would be most people, but i think it would certainly be useful to anyone using a custom configuration (ghacks user.js) to display the browser preference name(s) that correspond to the items in the blocked standards list (where applicable) so that these prefs could be reset if the user would rather control this functionality dynamically with API Manager on a per-domain basis

i think it might also be good to link the browser preference name to (in the case of FF for instance) the Moz KB page (kb.mozillazine.org) since it offers a more usable and general description verses many of the current "info" links

fooling with yet another extension in addition to a user.js, uBO, uM, etc., is less than desirable, but if it can eventually make some of this other privacy/security stuff obsolete, then i think it would be attractive to more people

thanks guys

Simple questions

Quoting from the author:

"We evaluated our extension with two hardened browser configurations, and found that blocking 15 of the 74 standards avoids 52.0% of code paths related to previous CVEs, and 50.0% of implementation code identified by our metric, without affecting the functionality of 94.7% of measured websites."

Please, I have the following simple questions:

  1. What does it mean in quantitative terms for the real word? In other words: How many security/privacy attacks occur today in the real world (based in APIs exploits/malwares/virus/hackers etc)?
    I ask for 3 reasons: a) I don't see adds-on or security software worrying about APIs; b) I can measure the risk of exploits/malwares/virus/ransomware/hackers etc, but I don't have quantitative info about API security breaches; and c) WebApiManager is a must for privacy. But I still don't understand the size of security benefits (for the real world). Obviously I understand that attacks could happen trough APIs. My point is that I don't know if today this is happening often or rarely.

  2. Even in the hypothetical case that today API security breaches are not often in quantitative terms for the real world, what about the future? It could be a trend? Are attackers trending to use APIs for hacking etc?

  3. Does WebApiManager increase browser performance? Decrease? No changes?

Thank you very much!

<all_urls> matching rule not working

That global pattern does not seem to be working, on 'default' is showing in the blocking rules pop-up.

To me the meaning of "Blocking of functionality across all domains, with a fallback, "default" blocking rule." is not not quite clear. How is 'default' a fallback, a fallback for what?

From my perspective it would make sense to start with a global rule blocking everything by default and then being able to dynamically ease (pop-up from the toolbar button) the rules for each domain needing relaxed rules, rather then tediously setting rules manually for each domain. For such dynamic setting there should be a general option to reload the page when new (relaxed) settings a applied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.