CSRF at https://chatstory.pixiv.net/imported
The endpoint that imports a novel as a chatstory did not verify the request's origin, so an attacker could make a logged-in user's browser submit a form that created a chatstory from the attacker's novel. This could trick users into importing the attacker's content.
Originally disclosed on HackerOne
- Triaged in 11 days
- Fixed in 31 days
- Paid in 11 days
- Disclosed after 15 months
Summary:
A CSRF in https://chatstory.pixiv.net/imported can trick users to import a novel of the attacker as the users' chatstory.
Steps To Reproduce:
- Attacker creates a novel
- Go to the novel (https://www.pixiv.net/novel/show.php?id=10997105) Import the novel as chatstory by clicking the "チャットストーリーを作る" on the sidebar. You show notice that the actual request to create a chatstory is a POST request to
https://chatstory.pixiv.net/importedwith body
id=<novel_id>&text=<something>&comment=<something>&title=<something>&user_id=<attacker_id>&x_restrict=0&is_original=true
- Use the above information to create a http post form. The <attacker_id> doesn't matter.
Supporting Material/References:
Please see the following "living" PoC:
`<html>
<body> <script>history.pushState('', '', '/')</script> <form action="https://chatstory.pixiv.net/imported" method="POST"> <input type="hidden" name="id" value="10997105" /> <input type="hidden" name="text" value="test<script>alert(1)</script> Title Normal Jump " /> <input type="hidden" name="comment" value="test&lt;script&gt;alert(1)&lt;/script&gt;" /> <input type="hidden" name="tags" value="#test" /> <input type="hidden" name="title" value="test<script>alert(1)</script>" /> <input type="hidden" name="user_id" value="39570048" /> <input type="hidden" name="x_restrict" value="0" /> <input type="hidden" name="is_original" value="true" /> <input type="submit" value="Submit request" /> </form> </body> </html> `Impact
Trick users to import novel of attacker as a chatstory
Context
pixiv hosts novels under www.pixiv.net, and a companion service at chatstory.pixiv.net turns a novel into a chat story. The import flow is the bridge between the two: from a novel page, a sidebar button labelled "チャットストーリーを作る" ("create a chat story") sends the novel's content to the chat story service, which creates a chat story owned by the logged-in user.
The report is about that import endpoint, https://chatstory.pixiv.net/imported. It accepts a POST request that carries the novel identifier, the text, a comment, a title, the user identifier, an age restriction flag and an originality flag. Because the endpoint acts on the authenticated user's session and the request is a plain form POST, it is a candidate for cross-site request forgery: any page on the internet can make a logged-in victim's browser submit the same form.
Setup
No special tooling is described.
The novel used throughout the report is https://www.pixiv.net/novel/show.php?id=10997105, and the user_id value in the PoC is 39570048.
Finding it
The researcher started from the legitimate feature and observed the request it sends. Clicking "チャットストーリーを作る" on the sidebar of a novel page does not produce a GET to a friendly URL; it produces a POST to https://chatstory.pixiv.net/imported with a body of the form:
id=<novel_id>&text=<something>&comment=<something>&title=<something>&user_id=<attacker_id>&x_restrict=0&is_original=true
That shape is the signal. The request is a standard form-encoded POST with no visible anti-CSRF token in the body. There is no visible anti-CSRF token in the body, and the researcher notes that the user_id parameter "doesn't matter", which suggests the server does not rely on it to decide ownership.
Exploitation
Step 1: create a novel
The attacker creates a novel on pixiv. This is the content that will be imported into the victim's account. The report does not describe the novel's contents beyond the text used in the PoC.
Step 2: observe the legitimate import request
The attacker opens the novel at https://www.pixiv.net/novel/show.php?id=10997105 and clicks "チャットストーリーを作る" in the sidebar. The browser sends the POST to https://chatstory.pixiv.net/imported with the body shown above. The parameters are:
| Parameter | Meaning in the request |
|---|---|
id |
the novel identifier |
text |
the novel body |
comment |
a comment string |
title |
the novel title |
user_id |
the attacker's user identifier |
x_restrict |
age restriction flag, 0 in the example |
is_original |
originality flag, true in the example |
Step 3: build a cross-site form
The attacker turns that request into an HTML page that submits the same fields to the same endpoint. The report's "living" PoC is:
<html>
<body>
<script>history.pushState('', '', '/')</script>
<form action="https://chatstory.pixiv.net/imported" method="POST">
<input type="hidden" name="id" value="10997105" />
<input type="hidden" name="text" value="test<script>alert(1)</script> Title Normal Jump " />
<input type="hidden" name="comment" value="test&lt;script&gt;alert(1)&lt;/script&gt;" />
<input type="hidden" name="tags" value="#test" />
<input type="hidden" name="title" value="test<script>alert(1)</script>" />
<input type="hidden" name="user_id" value="39570048" />
<input type="hidden" name="x_restrict" value="0" />
<input type="hidden" name="is_original" value="true" />
<input type="submit" value="Submit request" />
</form>
</body>
</html>
The form targets https://chatstory.pixiv.net/imported with method="POST" and carries the same fields as the legitimate request, plus a tags field (#test) that the researcher added. The PoC includes a history.pushState('', '', '/') call. The HTML entities in the values (<, >, (, /, , _) are just encodings of <, >, (, /, carriage return and line feed, and underscore; the browser decodes them before submitting, so the server receives the literal characters. The researcher states explicitly that the user_id value does not matter.
Step 4: deliver it to a logged-in victim
When a victim who is logged in to pixiv loads the attacker's page, the browser submits the form to chatstory.pixiv.net and attaches the victim's session. The intended result is that the attacker's novel becomes a chat story in the victim's account. The report does not show the server's response to the forged request.
Root cause
The import endpoint accepts a state-changing POST that is fully described by its form parameters, and the report shows no anti-CSRF token among them. Authentication therefore rests entirely on the session cookie, which the browser sends with any cross-site form submission. The user_id parameter is present but, per the researcher, irrelevant, so the server is not using it as a binding check either. The report does not analyse the root cause or which defences existed.
Impact
An attacker can trick a logged-in user into importing the attacker's novel as a chat story under that user's account. The report frames the impact exactly that way: "Trick users to import novel of attacker as a chatstory". The program rated it medium severity and paid a 500 USD bounty.
Fix
Variants to test
- Same endpoint, different content type. Submit the same fields as
multipart/form-dataortext/plainand see whether the server still parses them. A positive result is a chat story created in the victim's account from a cross-site page. - Token present but not enforced. If the legitimate form carries a token, remove it or reuse one from another session. A positive result is a successful import with a missing or foreign token.
- Token bound to the wrong thing. If the token is tied to the novel rather than the session, try a token harvested from the attacker's own import of the same novel. A positive result is the victim's import succeeding with the attacker's token.
- Other state-changing endpoints on the same host. Look for sibling POSTs (delete, edit, publish) that share the form-encoded style and test them the same way. A positive result is any of them acting on the victim's account from a cross-site page.
user_idtrust. Changeuser_idto another account's identifier and observe whether the created object lands under that account. A positive result is content created for a user who never submitted the request.
Hunting notes
This bug lives in the seam between two products: a content site and a companion service that imports content from it. Import, clone, share and "create from" buttons are good places to look, because they often post a full copy of the source object and are built quickly around an existing session. During recon, watch for form-encoded POSTs whose parameters mirror the source object's fields (id, text, title, user_id) and for endpoints that accept a user_id the client supplies. The researcher provided a cross-site form that reproduces the legitimate request.
What happened, in plain words
pixiv is a website where people publish novels. A companion service at chatstory.pixiv.net turns one of those novels into a "chat story", a different format of the same content. On a novel page there is a sidebar button labelled "チャットストーリーを作る" ("create a chat story"). When you click it, your browser quietly sends the novel's content to the chat story service, and the service creates a chat story in your account.
The researcher found that this import step can be triggered from any other website. If you are logged in to pixiv and you visit a page the attacker controls, that page can make your browser send the same import request, and the chat story service will treat it as if you had clicked the button yourself. The result is that the attacker's novel ends up as a chat story in your account, without you ever asking for it.
This kind of bug is called cross-site request forgery, or CSRF. The everyday comparison: imagine a bank that accepts a withdrawal slip with no signature, only the fact that the person handing it over is standing at the counter. Anyone who can get you to walk to the counter and hand over a slip they prepared can make the withdrawal happen in your name. The website equivalent of "standing at the counter" is your browser automatically attaching your login cookie to every request it sends to that site.
The pieces involved
Before the steps, here is what each part is, from zero.
- A novel page: a normal web page at
www.pixiv.netshowing a story. It has a sidebar with buttons, one of which is the "create a chat story" button. - The chat story service: a separate website at
chatstory.pixiv.net. It is a different host name, so the browser treats it as a different site. - An endpoint: a specific address on a server that does a specific job.
https://chatstory.pixiv.net/importedis the endpoint that performs the import. Think of it as a particular counter in a building: the address gets you to the building, the endpoint gets you to the right counter. - A POST request: one of the ways a browser talks to a server. A GET request is like asking to see a page; a POST request is like handing over a filled-in form that asks the server to change something. Here the POST asks the server to create a chat story.
- Form parameters: the fields of that form. They travel in the request body as pairs of a name and a value, for example
title=.... The server reads them to know what to create. - A session cookie: a small piece of data your browser stores after you log in, and sends automatically with every request to that site. It is how the server recognises you without asking for your password each time. Because it is sent automatically, a request coming from a page on another site also carries it.
- A CSRF token: a secret, unpredictable value that a well-built site puts into each form and checks on the server. A page on another site cannot know it, so a forged form fails. The report shows no such token in the import request.
- Cross-site request forgery (CSRF): the bug where a page on one site makes your browser send a state-changing request to another site, using your automatic login there.
Setup
The novel used throughout the report is https://www.pixiv.net/novel/show.php?id=10997105, and the user_id value in the proof of concept is 39570048.
Finding it
The researcher started from the legitimate feature and observed the request it sends. Clicking "チャットストーリーを作る" on the sidebar of a novel page does not produce a simple page view; it produces a POST to https://chatstory.pixiv.net/imported with a body of the form:
id=<novel_id>&text=<something>&comment=<something>&title=<something>&user_id=<attacker_id>&x_restrict=0&is_original=true
Line by line, this is one long string of name and value pairs joined by &:
id=<novel_id>: which novel to import. The angle brackets are placeholders, not literal text.text=<something>: the body of the novel.comment=<something>: a comment string.title=<something>: the novel's title.user_id=<attacker_id>: a user identifier. The researcher notes this value "doesn't matter".x_restrict=0: an age restriction flag, set to0in the example.is_original=true: an originality flag, set totruein the example.
That shape is the signal. The request is a standard form-encoded POST with no visible anti-CSRF token in the body. There is no visible anti-CSRF token in the body, and the researcher notes that the user_id parameter "doesn't matter", which suggests the server does not rely on it to decide ownership.
Exploitation
Step 1: create a novel
The attacker creates a novel on pixiv. This is the content that will be imported into the victim's account. The report does not describe the novel's contents beyond the text used in the proof of concept.
Step 2: observe the legitimate import request
The attacker opens the novel at https://www.pixiv.net/novel/show.php?id=10997105 and clicks "チャットストーリーを作る" in the sidebar. The browser sends the POST to https://chatstory.pixiv.net/imported with the body shown above. The parameters are:
| Parameter | Meaning in the request |
|---|---|
id |
the novel identifier |
text |
the novel body |
comment |
a comment string |
title |
the novel title |
user_id |
the attacker's user identifier |
x_restrict |
age restriction flag, 0 in the example |
is_original |
originality flag, true in the example |
Step 3: build a cross-site form
The attacker turns that request into an HTML page that submits the same fields to the same endpoint. The report's "living" proof of concept is:
<html>
<body>
<script>history.pushState('', '', '/')</script>
<form action="https://chatstory.pixiv.net/imported" method="POST">
<input type="hidden" name="id" value="10997105" />
<input type="hidden" name="text" value="test<script>alert(1)</script> Title Normal Jump " />
<input type="hidden" name="comment" value="test&lt;script&gt;alert(1)&lt;/script&gt;" />
<input type="hidden" name="tags" value="#test" />
<input type="hidden" name="title" value="test<script>alert(1)</script>" />
<input type="hidden" name="user_id" value="39570048" />
<input type="hidden" name="x_restrict" value="0" />
<input type="hidden" name="is_original" value="true" />
<input type="submit" value="Submit request" />
</form>
</body>
</html>
Line by line:
<html>,<body>: the ordinary skeleton of a web page.<script>history.pushState('', '', '/')</script>: a small script that rewrites the address bar so the page looks like it lives at the site root. The PoC includes ahistory.pushState('', '', '/')call.<form action="https://chatstory.pixiv.net/imported" method="POST">: opens a form whose destination is the import endpoint and whose method is POST, the method that asks the server to change something.- Each
<input type="hidden" ... />is a field the victim never sees.nameis the parameter name the server expects,valueis what will be sent. The fields mirror the legitimate request:id,text,comment,title,user_id,x_restrict,is_original. The researcher also added atagsfield with the value#test, which was not in the observed body. - The HTML entities in the values are just encodings.
<is<,>is>,(is(,/is/, is a carriage return followed by a line feed (a new line),_is an underscore,#is#, and&is&. The browser decodes them before submitting, so the server receives the literal characters. They are written this way because a raw<or&inside an HTML attribute would otherwise be read as markup. <input type="submit" value="Submit request" />: the button that sends the form. The report shows the submit button.- The researcher states explicitly that the
user_idvalue does not matter.
Step 4: deliver it to a logged-in victim
When a victim who is logged in to pixiv loads the attacker's page, the browser submits the form to chatstory.pixiv.net and attaches the victim's session. The intended result is that the attacker's novel becomes a chat story in the victim's account. The report does not show the server's response to the forged request.
Root cause
The import endpoint accepts a state-changing POST that is fully described by its form parameters, and the report shows no anti-CSRF token among them. Authentication therefore rests entirely on the session cookie, which the browser sends with any cross-site form submission. The user_id parameter is present but, per the researcher, irrelevant, so the server is not using it as a binding check either. The report does not analyse the root cause or which defences existed.
Impact
An attacker can trick a logged-in user into importing the attacker's novel as a chat story under that user's account. The report frames the impact exactly that way: "Trick users to import novel of attacker as a chatstory". The program rated it medium severity and paid a 500 USD bounty.
Fix
Variants to test
- Same endpoint, different content type. Submit the same fields as
multipart/form-dataortext/plainand see whether the server still parses them. A positive result is a chat story created in the victim's account from a cross-site page. - Token present but not enforced. If the legitimate form carries a token, remove it or reuse one from another session. A positive result is a successful import with a missing or foreign token.
- Token bound to the wrong thing. If the token is tied to the novel rather than the session, try a token harvested from the attacker's own import of the same novel. A positive result is the victim's import succeeding with the attacker's token.
- Other state-changing endpoints on the same host. Look for sibling POSTs (delete, edit, publish) that share the form-encoded style and test them the same way. A positive result is any of them acting on the victim's account from a cross-site page.
user_idtrust. Changeuser_idto another account's identifier and observe whether the created object lands under that account. A positive result is content created for a user who never submitted the request.
Hunting notes
This bug lives in the seam between two products: a content site and a companion service that imports content from it. Import, clone, share and "create from" buttons are good places to look, because they often post a full copy of the source object and are built quickly around an existing session. During recon, watch for form-encoded POSTs whose parameters mirror the source object's fields (id, text, title, user_id) and for endpoints that accept a user_id the client supplies. The researcher provided a cross-site form that reproduces the legitimate request.
Glossary
- API: a set of addresses on a server that programs and pages talk to in order to read or change data, as opposed to pages meant for a human to read.
- Endpoint: one specific address on a server that performs one specific job, such as
https://chatstory.pixiv.net/imported. - GET request: a request that asks a server to return something, typically a page, without changing data.
- POST request: a request that hands data to a server and asks it to change something, such as creating a chat story.
- Request body: the part of a request that carries the data, as opposed to the address and headers.
- Form-encoded: a way of writing data as
name=valuepairs joined by&, the format a plain HTML form produces. - Parameter: one named field in a request, for example
titleoruser_id. - Session cookie: a small value your browser stores after login and sends automatically with every request to that site, so the server knows who you are.
- Session: the server-side record of your logged-in state, identified by your session cookie.
- CSRF token: an unpredictable value placed in a form and checked by the server, which a page on another site cannot know, used to block forged requests.
- Cross-site request forgery (CSRF): a bug where a page on one site makes your browser send a state-changing request to another site using your automatic login there.
- State-changing request: a request that creates, edits or deletes something on the server, as opposed to one that only reads.
- HTML entity: an encoding such as
<for<or_for_, used so special characters can sit safely inside HTML. history.pushState: a browser function that changes the address bar without loading a new page.- Proof of concept (PoC): a small, working example that demonstrates a bug, here an HTML page that submits the forged form.
Origin/Referervalidation: a server-side check of which site a request came from, used as a defence against forged requests.SameSitecookie attribute: a setting that tells the browser not to send a cookie with requests coming from other sites.multipart/form-dataandtext/plain: alternative ways a browser can encode form data in a request body.- Recon: the information-gathering phase of security testing, where you watch what a site sends and look for interesting endpoints.
- Severity: the rating a bug program gives a report, here medium.
- Bounty: the money a bug program pays for a valid report, here 500 USD.