go.filepath-clean-misuse

返回列表 · CWE 索引

goERROR规则详情

各语言消息对照

语言消息
de

`Clean` ist nicht dazu gedacht, vor Path-Traversal-Angriffen zu schützen. Die Funktion ermittelt den kürzesten zum Eingabewert äquivalenten Pfadnamen. Wird `Clean` zur Bereinigung von Dateizugriffen verwendet, kann das die Anwendung für Path-Traversal-Angriffe öffnen, bei denen ein Angreifer beliebige Dateien auf dem Server lesen könnte. Eine einfache Korrektur ist: `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))`. Besser ist jedoch die Funktion `SecureJoin` aus dem Paket `filepath-securejoin`. Siehe https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.

en

`Clean` is not intended to sanitize against path traversal attacks. This function is for finding the shortest path name equivalent to the given input. Using `Clean` to sanitize file reads may expose this application to path traversal attacks, where an attacker could access arbitrary files on the server. To fix this easily, write this: `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))` However, a better solution is using the `SecureJoin` function in the package `filepath-securejoin`. See https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.

fr

`Clean` n'a pas vocation à se prémunir contre les traversées de répertoires : cette fonction cherche simplement le nom de chemin le plus court équivalent à l'entrée donnée. Utiliser `Clean` pour assainir des lectures de fichiers expose l'application à une traversée de répertoires, avec laquelle un attaquant peut accéder à n'importe quel fichier du serveur. Correction simple : `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))` ; mieux encore, utilisez la fonction `SecureJoin` du paquet `filepath-securejoin`. Voir https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme.

ja

`Clean` の設計目標はパストラバーサル攻撃を防ぐことではなく、入力と等価な最短のパス名を得ることだけです。`Clean` をファイル読み取りのサニタイズに使用すると、アプリケーションがパストラバーサル攻撃に晒され、攻撃者がサーバー上の任意のファイルにアクセスできてしまいます。簡単な修正方法は `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))` の使用です。より良い解決策は、`filepath-securejoin` パッケージの `SecureJoin` 関数を使用することです。詳細は https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme を参照してください。

ko

`Clean`의 설계 목표는 경로 횡단 공격 방어가 아니라 입력과 등가인 가장 짧은 경로명을 얻는 것입니다. `Clean`을 사용해 파일 읽기를 정제하면 애플리케이션이 경로 횡단 공격에 노출되어 공격자가 서버의 임의 파일에 접근할 수 있습니다. 간단한 수정 방법: `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))`; 더 나은 방법은 `filepath-securejoin` 패키지의 `SecureJoin` 함수를 사용하는 것입니다. 자세한 내용은 https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme 에서 확인하십시오.

ru

`Clean` не предназначен для защиты от обхода каталогов — функция лишь находит кратчайшее имя пути, эквивалентное входному. Очищать им файловые чтения опасно: атакующий сможет прочитать произвольные файлы на сервере. Простое исправление: `filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))`; ещё лучше — функция `SecureJoin` из пакета `filepath-securejoin`. См. https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme .

zh

`Clean` 的设计目标不是防御路径穿越攻击,它只求得到与输入等价的最短路径名。用 `Clean` 来净化文件读取会使应用暴露于路径穿越攻击,攻击者可访问服务器上的任意文件。简单修法:`filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))`;更好的方案是使用 `filepath-securejoin` 包的 `SecureJoin` 函数。参见 https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme 。

zh-Hant

`Clean` 的設計目標不是防禦路徑穿越攻擊,它只求得到與輸入等價的最短路徑名。用 `Clean` 來淨化檔案讀取會使應用暴露於路徑穿越攻擊,攻擊者可存取伺服器上的任意檔案。簡單修法:`filepath.FromSlash(path.Clean("/"+strings.Trim(req.URL.Path, "/")))`;更好的方案是使用 `filepath-securejoin` 包的 `SecureJoin` 函式。參見 https://pkg.go.dev/github.com/cyphar/filepath-securejoin#section-readme 。

CWE 知识卡

语言名称修复建议
dePath TraversalVerweigern Sie Pfade mit `..` und beschränken Sie den aufgelösten realen Pfad auf das Basisverzeichnis.
en——
frLimitation inappropriée d'un nom de chemin à un répertoire restreintRefusez les chemins contenant `..` et contraintez le chemin réel résolu à l'intérieur du répertoire de base.
jaパストラバーサル`..` を含むパスを拒否し、解決後の実パスを基準ディレクトリ内に制限してください。
ko경로 횡단`..` 포함 경로는 거부하고, 해석된 실제 경로는 기준 디렉터리 내로 제한하십시오.
ruОбход каталоговОтклоняйте пути, содержащие `..`, и удерживайте разрешённый реальный путь внутри базового каталога.
zh路径穿越拒绝包含 `..` 的路径,并将解析后的真实路径约束在基准目录内。
zh-Hant路徑穿越拒絕包含 `..` 的路徑,並將解析後的真實路徑約束在基準目錄內。

OWASP

A05:2017 - Broken Access ControlA01:2021 - Broken Access Control

元数据

likelihoodMEDIUM
impactMEDIUM
confidenceMEDIUM

修复字段

fix有
fix-regex无

上游规则源

github.com/opengrep/opengrep-rules/tree/main/go/lang/security/filepath-clean-misuse.yaml