Cursor pagination doesn't validate the cursor position or page size
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
Start with ValuesViewsetCursorPagination in contentcuration/contentcuration/utils/pagination.py, ContentNodePagination in contentcuration/contentcuration/viewsets/contentnode.py, and OptionalContentNodePagination in contentcuration/kolibri_public/views.py; compare how each handles cursor positions, ordering and page size. Reproduce the listed requests and add regression tests for each input, including the import metadata endpoint. Done means malformed cursors return DRF's invalid-cursor 404, ignored ordering cursors do not affect /api/contentnode, and public content-node pages respect a maximum size.
索引モデルが issue の本文から書いたものです。
説明
Overview
Cursor pagination passes the cursor's position to the queryset filter without checking it fits the ordering field, and the public contentnode endpoint has no maximum page size. A crafted cursor, or a huge max_results, raises an exception and the request returns 500. Two of the affected endpoints are anonymous.
Complexity: Medium
Target branch: hotfixes
Context
All inputs below were reproduced:
ValuesViewsetCursorPaginationrelies on DRF'sCursorPagination.decode_cursor, which validates the cursor's offset and direction but not its position (p). A base64 cursor ofp=abcorp=notadatereaches the filter on:/api/public/v2/contentnode/?max_results=2&cursor=cD1hYmM=:ValueError: Field 'lft' expected a number but got 'abc'. Anonymous./api/channelversion?version__gte=0&max_results=5&cursor=<p=abc>:ValueErroronversion. Anonymous./api/communitylibrary_submission?max_results=5&cursor=<p=notadate>: DjangoValidationErroron the datetime.ImportMetadataPaginationon/api/public/v2/importmetadata/<id>/orders bylftthe same way. Anonymous. Not reproduced separately.
ContentNodePaginationreads the cursor field from the raworderingparam and only checks the value is an integer when that field islft. On/api/contentnode?parent=<id>&max_results=2:&ordering=foo&foo__gt=abcraisesValueErroronlft, because DRF falls back tolftordering.&ordering=modified&modified__gt=abcraises DjangoValidationError.- Related: #4854.
OptionalContentNodePaginationsets nomax_page_size. On/api/public/v2/contentnode/,?max_results=999999999999999999999999999999raisesDataError: bigint out of range. Related: learningequality/kolibri#15826.
The Change
- A cursor position that doesn't fit the ordering field should get the same response DRF gives for any malformed cursor.
ContentNodePaginationshould take its cursor field from the ordering the viewset applies, not the raworderingparam.OptionalContentNodePaginationshould capmax_results.
Acceptance Criteria
General
- Every cursor input in Context, and the same cursor on
/api/public/v2/importmetadata/<id>/, returns DRF's invalid-cursor 404 instead of 500. -
/api/contentnodeignores a cursor param for anorderingit doesn't apply, and returns a 4xx for a cursor value of the wrong type for the ordering it applies. -
/api/public/v2/contentnode/with amax_resultsabove the cap returns at most the cap.
Testing
- Each input in Context has a regression test.
AI usage
I scoped the audit and chose the validation strategy in #6387. Claude Code found and reproduced these failures and drafted this issue.
- 主要言語
- Python
- スター
- 212
- フォーク
- 321
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
learningequality/studio のほかの issue
-
Community library status changes don't update `date_updated`対応中かも @ArpitaSamanta10 が今日担当しました。 オープンcommunity-contribution-in-progress DEV: backend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
learningequality/studio#6414 · コメント 8 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
learningequality/studio#6410 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
learningequality/studio#6409 ·
メンテナーはふだん 1 日以内に返信
-
DEV: backend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
learningequality/studio#6407 ·
メンテナーはふだん 1 日以内に返信
-
Stripe webhook accepts events when no webhook secret is configured対応中かも @adibmbrk が今日担当しました。 オープンcommunity-contribution-in-progress DEV: backend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
learningequality/studio#6404 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
learningequality/studio の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
audit-reference-check
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
site-bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
canonical/paas-charm#407 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信