Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

False Negative:ArrayIndexOutOfBounds.ql

オープン
#21,528 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

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

調査の方向性

Likely Bugs/Collections/ArrayIndexOutOfBounds.ql から始め、直接的な配列アクセスと、ヘルパーメソッド、エイリアス、計算されたインデックスを使用するアクセスをどのように処理しているか比較します。Issue の Java の例を再現し、その後、負のインデックスを含む、範囲外の各アクセスを query が報告することを確認します。

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

説明

Version
codeql 2.23.9

When I detect the code like this using Likely Bugs/Collections/ArrayIndexOutOfBounds.ql, the problem is reported normally:

package scensct.core.pos;
public class PosCase1 {
    public static void main(String[] args) {
        int[] arr = new int[5];
        int index = 10; // Unbounded index, no constraint check before access
        int value = arr[index]; // Direct access with potentially out-of-bounds index // [REPORTED LINE]
    }
}

However, when I use a mediator variable or call a mediator function, ArrayIndexOutOfBounds.ql fails to detect the problem:

package scensct.var.pos;

public class PosCase1_Var4 {
    public static void main(String[] args) {
        int[] arr = createArray();
        int index = getIndex();
        int value = arr[index]; // Access with index from method
    }

    private static int[] createArray() {
        return new int[5];
    }

    private static int getIndex() {
        return 10;
    }
}

package scensct.var.pos;

public class PosCase2_Var4 {
    public static void main(String[] args) {
        int[] arr = new int[5];
        int K = 5;
        // Introduce an alias reference
        int[] alias = arr;
        int index = K;
        int value = alias[index];
    }
}

package scensct.var.pos;

public class PosCase2_Var5 {
    private static int getIndex(int k) {
        return k;
    }

    public static void main(String[] args) {
        int[] arr = new int[5];
        int K = 5;
        // Move index computation to a helper method
        int index = getIndex(K);
        int value = arr[index];
    }
}
package scensct.core.pos;

public class PosCase3 {
    public static void main(String[] args) {
        int[] arr = new int[5];
        int K = -1; // Negative bound
        int index = K + 0; // Index bounded below by negative K
        int value = arr[index]; // Access with potentially negative index
    }
}
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 16時間
マージ済み PR(30日)
143

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

Security の issue をもっと見る

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

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