Skip to content

Commit 81a0f27

Browse files
committed
DataTransfer: public access: Security fix: session fixation (without loosing multiple area login).
1 parent d09ff38 commit 81a0f27

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

plugins/org.projectforge.plugins.datatransfer/src/main/kotlin/org/projectforge/plugins/datatransfer/restPublic/DataTransferPublicSession.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class DataTransferPublicSession {
9494

9595
/**
9696
* Tries to log-in the user. Uses LoginProtection. Doesn't check if the user is already logged-in.
97+
* The session id will be changed (session fixation), but any previous logged-in area will be put in the new session.
9798
*/
9899
internal fun login(
99100
request: HttpServletRequest,
@@ -134,6 +135,18 @@ class DataTransferPublicSession {
134135
// Successfully logged in:
135136
loginProtection.clearLoginTimeOffset(accessToken, null, clientIpAddress)
136137
log.info { "Data transfer area with externalAccessToken '$accessToken': login successful by ip=$clientIpAddress, userInfo='$userInfo'." }
138+
139+
// Session Fixation: Change JSESSIONID after login (due to security reasons / XSS attack on login page)
140+
request.getSession(false)?.let { session ->
141+
if (!session.isNew) {
142+
val map = getSessionMap(request)
143+
session.invalidate()
144+
if (map != null) {
145+
// Save any logged-in areas from old session and restore in nes session:
146+
request.getSession(true).setAttribute(SESSION_ATTRIBUTE, map)
147+
}
148+
}
149+
}
137150
register(request, dbo, userInfo)
138151
return CheckAccessResult(dbo)
139152
}

0 commit comments

Comments
 (0)