Giter Site home page Giter Site logo

shadowcrypt's People

Contributors

sumeet-jain 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

Watchers

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

shadowcrypt's Issues

OS X Chrome, Twitter: Can't type

I can't type while the extension is enabled, making it unusable. It continuously goes out of focus. Lock icon is also very buggy.

Reddit keyboard bug

When submitting a text submission to Reddit with the extension enabled the arrow keys and the backspace key move/remove two characters for every key press. Here is a video showing this in action http://quick.as/ao2jcxq8.

TOCTOU bug. shadowRoot property modified _after_ node is added to the DOM tree.

This is less important, given that shadowRoot is no longer a property in recent versions of Chrome.

The protections of the content script should still be put in place on objects and prototypes before the application has a chance to use them.

inputBox.parentNode.removeChild(inputBox);
inputBox = inputBox.cloneNode();
Object.defineProperty(inputBox, "shadowRoot", {configurable: false});
parentBox.appendChild(inputBox);

The page code above makes the shadowRoot property non configurable on the object before it is added to the DOM. The mutation observer in shadowcrypt (the one in charge of deleting that attribute) runs only after the element is added. Reconfiguration will fail.

Would be a good idea to make sure the properties modified have the expected flags before they are modified.

Unencrypted value can be accessed with element.shadowRoot.querySelector or element.shadowRoot

I put a proof-of-concept at http://s.codepen.io/danielzfranklin/debug/YwvVVP.

If the browser supports it, element.shadowRoot.querySelector can be used to access the underlying element. It works in Chrome 48 but does not appear to be in the W3C standard. Otherwise, element.shadowRoot.activeElement can be polled until the input field is clicked on, activeElement is standardized in the spec at http://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface

if var input = [an input element secured by shadowcrypt] the following code will try both methods to get the contents of the shadow input.

function found_shadow_input(shadow_input){
    // Do whatever on the DOM node of the shadow_input
    // attach listeners, log the value, etc.
}

function break_into_shadowroot(){
    if(input.shadowRoot.querySelector){
        // find using querySelector
        found_shadow_input(input.shadowRoot.querySelector("input.delegate"));
        console.log("found using querySelector");
    }
    else{
        // poll activeElement until the user clicks on the input
        var shadow_input_searcher = setInterval(function(){
            var potential_elem = input.shadowRoot.activeElement;

            if(potential_elem && potential_elem.nodeName === "INPUT" && potential_elem.classList.contains("delegate")){
                clearInterval(shadow_input_searcher);
                found_shadow_input(potential_elem);
                console.log("found using activeElement");
            }
        }, 10);
    }
}

if(input.shadowRoot){
    break_into_shadowroot();
}
else{
    // if the extension hasn't loaded yet we may need to wait a few milliseconds
    var shadowroot_check_interval = setInterval(function(){
        if(input.shadowRoot){
            clearInterval(shadowroot_check_interval);
            break_into_shadowroot();
        }
    }, 10)
}

element.shadowRoot.querySelector is read-only so you can't monkeypatch it to fix this. What you use something else instead of an input element? A span could have its contents accessed with .innerHTML, but a dirty canvas can't be read off of. If you watched for keypresses and wrote them to a canvas if they were alphanumeric/symbols, moved a fake blinking cursor on arrow key press, moved the cursor on mouse click, and deleted letters on delete key press you could create a custom input element. If a clear pixel from a different domain was written in a corner, the canvas couldn't be read off of.

Page closure uses methods possibly overridden by page.

When the project is refactored to match Chrome's move from properties to getters on DOM objects, it should also be refactored to use methods local to the "within" closure.

It is currently possible for an adversarial page to modify prototype methods, such as RegExp.test to allow /deep/ selectors and get access to .delegate objects despite checks done inside shadowcrypt.

function allowDeep() {
    if (this.toString() === "/\/deep\/|>>>/") {
        return false;
    }
}
RegExp.prototype.test = allowDeep;

`body /deep/ span` reveals cleartext

The /deep/ combinator can cross the shadow boundary, allowing a host script read/write access the same cleartext DOM presented to the user.

A parent application can easily get all ShadowCrypt cleartext on a page:

[].slice.call(document.querySelectorAll('body /deep/ span'))
.map(function(el) {
  return el.innerText
}).join('\n')

Not sure there's a way around it at this point.

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.