-
-
Notifications
You must be signed in to change notification settings - Fork 389
fix(session): decode canonical detail route identities #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,15 +53,24 @@ import { SessionMessagesDetailsTabs } from "./session-details-tabs"; | |
| import { hasSnapshotData } from "./session-messages-guards"; | ||
| import { SessionStats } from "./session-stats"; | ||
|
|
||
| function normalizeCanonicalSessionRouteParam(sessionId: string): string { | ||
| try { | ||
| const decoded = decodeURIComponent(sessionId); | ||
| return decoded.startsWith("pfx:") || decoded.startsWith("sid:") ? decoded : sessionId; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] [LOGIC-BUG] Double-decoding the route param can rewrite a valid physical Session ID Why this is a problem: Suggested fix: const params = useParams<{ sessionId: string }>();
const sessionId = params.sessionId;Then update the regression test to mock the runtime value that Next actually provides ( |
||
| } catch { | ||
| return sessionId; | ||
| } | ||
| } | ||
|
|
||
| export function SessionMessagesClient() { | ||
| const t = useTranslations("dashboard.sessions"); | ||
| const tErrors = useTranslations("errors"); | ||
|
|
||
| const params = useParams(); | ||
| const params = useParams<{ sessionId: string }>(); | ||
| const searchParams = useSearchParams(); | ||
| const router = useRouter(); | ||
| const pathname = usePathname(); | ||
| const sessionId = params.sessionId as string; | ||
| const sessionId = normalizeCanonicalSessionRouteParam(params.sessionId); | ||
|
|
||
| // URL state | ||
| const seqParam = searchParams.get("seq"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a valid client-supplied physical ID contains percent text that decodes to a reserved prefix, such as
pfx%3Afoo,buildPublicSessionIdentitydeliberately preserves it because the raw ID does not begin withpfx:orsid:. Next.js already percent-decodes dynamic route parameters (also documented insrc/app/api/ip-geo/[ip]/route.ts:36), so a correctly encoded link for that ID suppliespfx%3Afoohere; this second decode changes it topfx:foo, causing detail, request-list, export, and termination operations to target a different identity. Preserve the framework-decoded parameter rather than decoding it again.Useful? React with 👍 / 👎.