dethcrypto / dethcrypto/dethcode

Path Traversal Issue in `Deth` Online Vscode Source Code Viewer

オープン
#99 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
1.4k
フォーク
109
PR マージ指標
30日以内にマージされた PR はありません

説明

## Path Traversal Issue in Deth Online Vscode Source Code Viewer
### Introduction
A path traversal Issue (../ file path issue) has been discovered in Deth's Vscode-based online source code viewer. This Issue allows attackers to shift verification paths to upper directories, thereby hiding specific real contract source files. This results in a source code forgery Issue, potentially enabling attackers to deceive users and auditors during contract verification.

By constructing a specially crafted JSON file for source code verification, an attacker can exploit flaws in Deth's directory handling mechanism. This causes the actual source file `../../a.sol` to be overwritten and hidden while displaying the fake malicious source file a.sol in the directory.

Using this Issue, attackers can replace verified contract code with malicious code, potentially misleading auditors or users into believing they are reviewing the legitimate source code.

## Example JSON
Below is an example JSON file demonstrating the Issue:

```json
{
"language": "Solidity",
"sources": {
"a.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Owner {
address private Hacker;
function bad(address newOwner) public {
Hacker = address(0x0);
}
}"
},
"../../a.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract Owner {
address private owner;
function changeOwner(address newOwner) public {
owner = newOwner;
}
}"
}
},
"settings": {}
}
```

By submitting this crafted JSON file, the actual source file `../../a.sol` is concealed, while the fake file `a.sol` with malicious code is displayed in the directory.

Image

Below are links illustrating the exploitation:

https://sepolia.etherscan.deth.net/address/0xb7e278f0116508c611f8a486666d3823e51c44dc

### Recommendations
* Implement strict path sanitization to prevent the use of `../` for directory traversal.

We also find same issue in [Forge](https://github.com/foundry-rs/foundry/issues/4896), Metasuite, Blockscan and [crytic-based ](https://github.com/crytic/crytic-compile/pull/425)tools like Slither. so this is a common issue for code fetcher tool but we also think this is a risky issue need to did some better pratice.

![Image](https://github.com/user-attachments/assets/0d8ba904-e5c4-4d21-b6e7-f7dc64b8ece3)

Thank you very much for providing such a powerful tool, it's a great convenience for us and hopefully this discovery will allow me to contribute something to the tool.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、Deth のオンライン VSCode ソースコードビューアーで作成済みの JSON 例を再現し、そのディレクトリ処理を追跡します。`../../a.sol` のようなパスが意図したソースディレクトリから脱出できず、正当なファイルが引き続き表示され、検証フローで実証されたソース偽装が許可されなくなれば、修正は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
solidity, typescript
領域
devtools, security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。