Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
ツール/GitHubGitHub/my0113/shiro-cve-2022-32532
認証と認可脆弱性分析エクスプロイトウェブアプリケーション悪用ペネトレーションテスト学習と教育
GitHubmy0113/shiro-cve-2022-32532

shiro-cve-2022-32532

CVE-2022-32532を再現するための最小限のJava Webアプリケーション。Apache ShiroのRegExPatternMatcherにおける、URL内の改行文字による認証バイパス。

リポジトリを見る
21年前未レビュー

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

Apache Shiro CVE-2022-32532 再現環境

これは CVE-2022-32532(Apache Shiro RegExPatternMatcher 認証バイパス)を再現するための最小限のWebアプリケーションです。

脆弱性の説明

  • CVE: CVE-2022-32532
  • 影響を受けるバージョン: Shiro < 1.9.1
  • 原因: RegExPatternMatcher が正規表現を正しくアンカーしておらず、パスバイパスが発生する可能性があります。具体的には、Javaのデフォルトの正規表現マッチングロジックを使用しており、正規表現で.記号が使用された場合、\r(%0d)や\n(%0a)のような特殊記号が無視されます。\r、\n記号を正しく処理するには、PATTERN.DOTALLモードに基づく正規表現マッチングルールを明示的に使用する必要があります。shiro-1.9.1未満のバージョンはすべてデフォルトの正規表現マッチングロジックを使用しているため、\r、\nを正しく処理できず、認証バイパスが発生します。

再現方法

  1. アプリケーションを起動します。

    root@kitploit:~
    启动ShiroCve202232532Application
    
    
  2. 通常のShiro認証で access denied を返すURLは以下のとおりです。
    http://localhost:8080/permit/xxx、最後のxxxは任意の文字に置き換えることができます。

  3. Shiroの認証をバイパスして success を返すURLは以下のとおりです。
    http://localhost:8080/permit/xxx、つまり最後のxxxに改行文字\n(%0a)、復帰文字\r(%0d)を挿入します。

  4. 解決方法

    1)https://github.com/apache/shiro/blob/shiro-root-1.9.1/core/src/main/java/org/apache/shiro/util/ から RegExPatternMatcher.java と PatternMatcher.java の全内容をコピーします。
    2)jdk11 を使用して、これら2つのJavaファイルを RegExPatternMatcher.class と PatternMatcher.class にコンパイルします。
    3)WinRAR を使用して、この2つの class ファイルを shiro-core-1.6.0.jar の org/apache/shiro/util/ の下に配置します。
    4)修正テストは、shiro-core-1.9.1 の RegExPatternMatcher.java のコードを本ケースにコピーして RegExPatternMatcher191.java に変更し、その後 MyFilter の15行目と MyShiroFilterFactoryBean の29行目の new RegExPatternMatcher() を new RegExPatternMatcher191() に変更するだけです。
    5)shiro-core-1.9.1 の RegExPatternMatcher の実装ロジックは以下のとおりです。

root@kitploit:~
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.shiro.util;

import java.util.regex.Pattern;
import java.util.regex.Matcher;

/**
 * {@code PatternMatcher} implementation that uses standard {@link java.util.regex} objects.
 *
 * @see Pattern
 * @since 1.0
 */
public class RegExPatternMatcher implements PatternMatcher {

   private static final int DEFAULT = Pattern.DOTALL;

   private static final int CASE_INSENSITIVE = DEFAULT | Pattern.CASE_INSENSITIVE;

   private boolean caseInsensitive = false;

   /**
    * Simple implementation that merely uses the default pattern comparison logic provided by the
    * JDK.
    * <p/>This implementation essentially executes the following:
    * <pre>
    * Pattern p = Pattern.compile(pattern, Pattern.DOTALL);
    * Matcher m = p.matcher(source);
    * return m.matches();</pre>
    * @param pattern the pattern to match against
    * @param source  the source to match
    * @return {@code true} if the source matches the required pattern, {@code false} otherwise.
    */
   public boolean matches(String pattern, String source) {
      if (pattern == null) {
         throw new IllegalArgumentException("pattern argument cannot be null.");
      }
      Pattern p = Pattern.compile(pattern, caseInsensitive ? CASE_INSENSITIVE : DEFAULT);
      Matcher m = p.matcher(source);
      return m.matches();
   }

   /**
    * Returns true if regex match should be case-insensitive.
    * @return true if regex match should be case-insensitive.
    */
   public boolean isCaseInsensitive() {
      return caseInsensitive;
   }

   /**
    * Adds the Pattern.CASE_INSENSITIVE flag when compiling patterns.
    * @param caseInsensitive true if patterns should match case-insensitive.
    */
   public void setCaseInsensitive(boolean caseInsensitive) {
      this.caseInsensitive = caseInsensitive;
   }
}
ツールをダウンロード