Skip to content

Commit 6a5bb3b

Browse files
Apply suggestion from @coderabbitai[bot]
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 79b63b6 commit 6a5bb3b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

server/api/auth/atproto.get.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export default defineEventHandler(async event => {
1515
}
1616

1717
const query = getQuery(event)
18-
const returnTo = query.returnTo?.toString() || '/'
18+
const rawReturnTo = query.returnTo?.toString() || '/'
19+
// Validate returnTo is a safe relative path (prevent open redirect)
20+
const isRelativePath = rawReturnTo.startsWith('/') && !rawReturnTo.startsWith('//') && !rawReturnTo.includes(':')
21+
const returnTo = isRelativePath ? rawReturnTo : '/'
1922

2023
setCookie(event, 'auth_return_to', returnTo, {
2124
maxAge: 60 * 5,

0 commit comments

Comments
 (0)