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

[Vulnerability] Atomic Rollback Failure in cJSONUtils_ApplyPatchesCaseSensitive leads to "Dirty State" on error

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

メンテナーはふだん 12 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
c
領域
backend

調査の方向性

まず cJSON_Utils.c を読み、特に cJSONUtils_ApplyPatchesCaseSensitive とその内部関数 apply_patch を確認します。最初のパッチは成功し、その後のパッチが失敗する Issue のパッチシーケンスを再現し、エラー後も以前の変更がどのように残るかを追跡します。失敗したパッチシーケンスによって元の JSON オブジェクトが変更されないままになるか、記載された rollback mechanism が提供されれば完了です。

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

説明

Clear and concise description of the bug:
The function cJSONUtils_ApplyPatchesCaseSensitive lacks transactional atomicity when applying a sequence of JSON patches. It utilizes an "in-place modification" strategy without creating a snapshot or backup of the original object.
If an error occurs in the middle of a patch sequence (e.g., a remove operation on a non-existent path), the function immediately returns an error code but does not revert the patches that were successfully applied earlier in the same call. This results in the target JSON object being left in an unpredictable "dirty" or partially modified state, which can be exploited for security bypasses (like privilege escalation) or cause data inconsistency.

Steps to reproduce the bug :
1.Prepare a base JSON object:

{ "status": "locked", "count": 1 }

2.Construct a malicious patch sequence with a "success-then-fail" logic:

[
  { "op": "replace", "path": "/status", "value": "unlocked" },
  { "op": "remove", "path": "/non_existent_path_to_force_error" }
]

3.Apply the patches using cJSONUtils_ApplyPatchesCaseSensitive
4.Observe the result: The function returns a non-zero error code (e.g., 13), but the status field in the original object has already been changed to "unlocked".

Expected behavior:
If cJSONUtils_ApplyPatchesCaseSensitive fails to apply the entire patch set, it should ensure the original JSON object remains unchanged (Atomicity), or provide a mechanism to roll back to the initial state.

Observed behavior:
The function returns an error, but the memory state of the object is permanently altered by the preceding successful patch operations.
Expected State after failure: {"status": "locked", "count": 1}
Actual Dirty State: {"status": "unlocked", "count": 1}

Platform(s) (compiler version, operating system version, CPU) on which the bug was observed:
OS: Ubuntu 20.04 LTS
Compiler: GCC 9.4.0
Build System: CMake 3.16.3

cJSON release(s), commit(s), or branch(es) in which the bug was observed:
cJSON(main branch)
Affected File: cJSON_Utils.c
Affected Function: cJSONUtils_ApplyPatchesCaseSensitive and internal apply_patch.

主要言語
C
スター
13k
フォーク
3.5k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

DaveGamble/cJSON のほかの issue

DaveGamble/cJSON の issue をすべて見る

似ている issue

C の issue をもっと見る

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

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