[Vulnerability] Atomic Rollback Failure in cJSONUtils_ApplyPatchesCaseSensitive leads to "Dirty State" on error
メンテナーはふだん 12 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず 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 はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DaveGamble/cJSON のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DaveGamble/cJSON#1106 ·
メンテナーはふだん 12 日以内に返信
-
Undefined-Behavior in function cJSON_SetNumberHelper対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
DaveGamble/cJSON#1100 · リアクション 1 件 ·
メンテナーはふだん 12 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
DaveGamble/cJSON#1094 · コメント 9 件 · リアクション 1 件 ·
メンテナーはふだん 12 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DaveGamble/cJSON#1093 ·
メンテナーはふだん 12 日以内に返信
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch array対応中かも @iliasabk が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
DaveGamble/cJSON#1082 ·
メンテナーはふだん 12 日以内に返信
DaveGamble/cJSON の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
kubernetes-sigs/security-profiles-operator#3597 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
AFLplusplus/AFLplusplus#2903 ·
-
Clean up stale and inaccurate comments in the platform screen and input files対応中かも @RichStephens が今日担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 88/100
FujiNetWIFI/fujinet-config#289 ·
メンテナーはふだん 1 日以内に返信
-
category:port-update
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
nasa/cFS-GroundSystem#272 ·