False negative in java/unvalidated-url-redirection for Spring MVC redirect view names
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
まず、安定版の java/unvalidated-url-redirection クエリと実験版の java/spring-unvalidated-url-redirection クエリを比較し、Spring のリダイレクトビュー名とヘルパーを介したフローに焦点を当てます。redirect:、ModelAndView、RedirectView の形式を含む、一覧に記載されたパターンを再現し、ユーザーが制御するターゲットが報告される一方で、安全なリダイレクトには影響がないことを確認します。
索引モデルが issue の本文から書いたものです。
説明
I ran into a false negative in the Java URL redirection queries for a common Spring MVC pattern.
java/unvalidated-url-redirection does not appear to cover redirects expressed through Spring view names like return "redirect:" + userControlledValue, especially when that construction is wrapped in a helper method.
I found this on a public CVE, CVE-2025-8813, in atjiu/pybbs.
Vulnerable code:
@GetMapping("changeLanguage")
public String changeLanguage(String lang, HttpSession session, HttpServletRequest request) {
String referer = request.getHeader("referer");
if ("zh".equals(lang)) {
session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.SIMPLIFIED_CHINESE);
} else if ("en".equals(lang)) {
session.setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, Locale.US);
}
return StringUtils.isEmpty(referer) ? redirect("/") : redirect(referer);
}
protected String redirect(String path) {
return "redirect:" + path;
}
This was fixed upstream by removing the user-controlled redirect target:
https://github.com/atjiu/pybbs/commit/edb14ff13e9e05394960ba46c3d31d844ff2deac
My understanding is that the stable query covers servlet-style redirect sinks such as sendRedirect(...) and Location headers, but not the Spring MVC redirect-by-view-name sink family. In this case the source is straightforward (request.getHeader("referer")) and the flow is short, so the gap seems to be sink coverage rather than source modeling.
This pattern is common in practice:
return "redirect:" + nextreturn new ModelAndView("redirect:" + next)return new RedirectView(next)- helper wrappers such as
redirect(next)in a base controller or utility class
That last form is especially common in real Spring code, so this is not just a one-off CVE shape. I would expect similar misses whenever a project centralizes redirect construction in a helper.
There is already an experimental query, java/spring-unvalidated-url-redirection, so this may just be a case where the relevant Spring sink modeling has not made it into the stable query set yet.
A reasonable fix might be to bring the Spring redirect sink coverage into the stable rule family, especially for:
"redirect:" + taintednew ModelAndView("redirect:" + tainted)new RedirectView(tainted)- helper-mediated variants that ultimately construct a Spring redirect view name
- 主要言語
- CodeQL
- スター
- 10.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 129
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/codeql のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
false-positive
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
False positive オープンfalse-positive
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
connectrpc/connect-py#342 ·
-
01 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
plone/cookieplone-templates#471 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
notch8/utk_knapsack#148 ·
-
helsemelding-json-schema json-schema-core
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100