You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix students landing on the Dashboard: refuse redirects before they are sent - #13
Since #8, a student who logs in under lockdown lands on Moodle's Dashboard instead of the quiz.
#8 re-issues main-frame redirects so each target gets SEB hashes for its own URL. In its last review round, I moved the decision into the request interceptor, so that 307/308 after a POST would keep their body. On Qt 6.2 that doesn't work. Chromium sends the redirected request before the interceptor can block it, and the block only aborts the connection afterwards. Moodle's access log from the live E2E:
POST /login/index.php 303
GET /login/index.php?testsession=3 499 <- redirect leg, sent with stale hashes, then aborted
GET /login/index.php?testsession=3 303 <- re-issue; the wanted page was already used up -> "/"
GET /my/ 499
GET /my/ 200 <- Dashboard
Moodle ran the aborted request anyway, so every GET redirect leg reached the server twice. Here the first testsession used up the page the student asked for. (This also explains why Qt 6.2 "keeps" the old headers on redirects: the leg is already sent by the time the interceptor runs.)
Fix
Refuse main-frame redirects in acceptNavigationRequest(), which runs before Chromium follows them, and load the target as a new navigation. That was the approach before #8's last round, and it passed the live E2E on Qt 6.2 and 6.4, in both file and link modes. The interceptor hook is removed.
Trade-off, stated in RedirectReissuePolicy.h: a 307/308 after a POST becomes a GET and loses its body. The interceptor version couldn't really keep it either, because its leg went out with stale hashes. LMS form posts answer with 302/303, which browsers follow with GET anyway.
Verified
Unit tests: test_redirect_reissue_policy rewritten for the new API (chain legs, cap, reset, fragments), 6/6 suites pass.
Live E2E (Moodle 5.3, full lockdown), on this branch plus feat: SEB Config Key + BEK computation with unit tests #12: PASS on Qt 6.2 (Ubuntu 22.04) and Qt 6.4 (Ubuntu 24.04). The student logs in, lands on the quiz and starts an attempt (Moodle attempts 0 -> 1), Moodle logs zero access_prevented, every main-frame request reaches Moodle once, and there are no aborted (499) requests.
Summary by CodeRabbit
Bug Fixes
Improved handling of main-frame redirects by loading redirect destinations as fresh navigations, so browser security checks can apply to them before they load.
Added protection against repeated redirect reissues, helping prevent redirect loops.
Redirect handling no longer depends on the original request using a specific HTTP method.
…ches the LMS once
Since a4c13d1 the request interceptor blocked redirect legs and re-issued them. On
Qt 6.2 the leg is already on the wire when the interceptor runs: Moodle's access log
shows it arrive, then a client abort (499), then the re-issue. The server runs both,
so Moodle's login "testsession" step consumed the page the student asked for and the
student landed on the Dashboard instead of the quiz.
Refuse main-frame redirects in acceptNavigationRequest(), which runs before Chromium
follows them, and load the target as a new navigation. The interceptor hook is gone. A
307/308 after a POST becomes a GET; LMS form posts answer with 302/303.
Live E2E (Moodle 5.3, full lockdown, with #12 on top): passes on Qt 6.2 and 6.4, every
main-frame request reaches Moodle once, no aborted requests.
Main-frame redirects are now checked during navigation acceptance. When the policy requests reissue, SecurePage rejects the redirect and schedules a fresh navigation to its URL. The request-interceptor hook and related forwarding methods are removed.
Changes: Redirect reissue flow
Layer / File(s)
Summary
Redirect policy and tests src/browser/RedirectReissuePolicy.h, tests/unit/test_redirect_reissue_policy.cpp
The policy uses the redirect flag to decide whether to reissue. It tracks the reissued URL and caps redirect reissues at 20. Tests cover redirect chains, normal navigations, disabled behavior, fragments, and the cap.
Navigation handling and interceptor cleanup src/browser/SecureBrowser.cpp, src/browser/SecureBrowser.h, src/core/LockdownEngine.cpp, src/protocol/SEBRequestInterceptor.*
SecurePage::acceptNavigationRequest checks main-frame redirects and schedules a fresh load when reissue is requested. The interceptor hook, its setup, and the related forwarding methods are removed.
oneKn8/openlock_browser#8: Introduced main-frame redirect cancellation and reloading in SecurePage; this PR updates that behavior and moves the decision into acceptNavigationRequest().
Merge Risk: Minimal · up to b386e
Main-frame redirects are now refused before they are sent and loaded as fresh navigations, which fixes students landing on the Dashboard. A 307/308 redirect after a form POST loses its body. This is a documented trade-off, and LMS form posts use 302/303. No merge-blocking risk was found.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly describes the primary change: refusing main-frame redirects before Chromium sends them to prevent students from landing on the Dashboard.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 7 functions across 4 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
What it changes: Main-frame redirects are now refused in SecurePage::acceptNavigationRequest() and the target is loaded as a new navigation. The interceptor hook, takeRedirectForReissue and the pending-redirect state in RedirectReissuePolicy are removed. The policy tests are rewritten for the new API.
Findings: I found no verified problems at this PR's head.
Critical: none.
Major: none.
Minor: none.
Checked in the code:
The scheme checks in acceptNavigationRequest() still run before shouldReissue(). A redirect to a blocked scheme is refused as before.
The navigation filter lives in the interceptor. The re-issued load(url) goes through the interceptor, so a redirect to a disallowed host is still blocked and still gets per-URL hashes.
Policy logic matches the tests. Non-redirect navigations reset the chain unless they are our own re-issued load. kMaxReissues caps the chain. Fragments are ignored when matching.
Could not verify:
I did not build the project or run the unit tests.
I did not run the live Moodle E2E on Qt 6.2 or 6.4. The claims of no 499s, one request per leg, and landing on the quiz rest on the PR description.
That acceptNavigationRequest() returning false for a redirect leaves no error page and no loadFinished(false) side effect on Qt 6.2 and 6.4 is covered only by the E2E.
The known trade-off (307/308 after a POST becomes a GET) is documented in the header, so I did not raise it as a finding.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
src/browser/SecureBrowser.cpp-68-68: 1
68-68: Major · Functional Correctness · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve POST requests across 307 and 308 redirects.
If an LMS or sign-in endpoint returns 307 or 308 after a form POST, load(url) starts a GET and drops the POST body. The redirect target cannot receive the submitted form data, so that form flow fails. Preserve the method and body for these redirects instead of replacing them with a URL-only load. HTTP defines 307 and 308 as method-preserving redirects. (rfc-editor.org)
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: db147e6a-ed27-48f4-b1dd-7ee4a5d425f7
Commits
Reviewing files that changed from the base of the PR and between c8a8d71 and b386ec1.
Files selected for processing: 7
src/browser/RedirectReissuePolicy.h
src/browser/SecureBrowser.cpp
src/browser/SecureBrowser.h
src/core/LockdownEngine.cpp
src/protocol/SEBRequestInterceptor.cpp
src/protocol/SEBRequestInterceptor.h
tests/unit/test_redirect_reissue_policy.cpp
Files with no reviewable changes: 3
src/protocol/SEBRequestInterceptor.cpp
src/core/LockdownEngine.cpp
src/protocol/SEBRequestInterceptor.h
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
On CodeRabbit's 307/308 point: that's the documented trade-off (RedirectReissuePolicy.h), not something this code can fix. acceptNavigationRequest() gets neither the status code nor the request body, so it can't tell a 307 from a 303. The only place that knows the method is the request interceptor, and on Qt 6.2 it runs after the redirected request is already sent, which is the bug this PR fixes. The interceptor version didn't really keep 307/308 either: the leg went out with the previous URL's SEB hashes. LMS form posts answer with 302/303, which browsers follow with GET anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #8, a student who logs in under lockdown lands on Moodle's Dashboard instead of the quiz.
#8 re-issues main-frame redirects so each target gets SEB hashes for its own URL. In its last review round, I moved the decision into the request interceptor, so that 307/308 after a POST would keep their body. On Qt 6.2 that doesn't work. Chromium sends the redirected request before the interceptor can block it, and the block only aborts the connection afterwards. Moodle's access log from the live E2E:
Moodle ran the aborted request anyway, so every GET redirect leg reached the server twice. Here the first
testsessionused up the page the student asked for. (This also explains why Qt 6.2 "keeps" the old headers on redirects: the leg is already sent by the time the interceptor runs.)Fix
Refuse main-frame redirects in
acceptNavigationRequest(), which runs before Chromium follows them, and load the target as a new navigation. That was the approach before #8's last round, and it passed the live E2E on Qt 6.2 and 6.4, in both file and link modes. The interceptor hook is removed.Trade-off, stated in
RedirectReissuePolicy.h: a 307/308 after a POST becomes a GET and loses its body. The interceptor version couldn't really keep it either, because its leg went out with stale hashes. LMS form posts answer with 302/303, which browsers follow with GET anyway.Verified
test_redirect_reissue_policyrewritten for the new API (chain legs, cap, reset, fragments), 6/6 suites pass.access_prevented, every main-frame request reaches Moodle once, and there are no aborted (499) requests.Summary by CodeRabbit