Skip to content

Commit

Permalink
Avoid some unwanted redirections, aka XSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiarn committed Feb 11, 2023
1 parent b83d7a4 commit 230ecff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugins/core/resources/js/core/controllers/login.controller.es
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ angular.module('core').controller('CoreLoginController', function($scope, $log,
$scope.mode = $routeParams.mode;
}

$scope.sanitizeNextPage = () => {
// Avoid some unwanted redirections
if ($routeParams.nextPage.substring(0,1) != '/') {
return '/';
} else {
return $routeParams.nextPage;
}
}

$scope.verify = ($event) => {
code = $event.code;
if (code.toString().length == 6) {
$scope.totp_attempts++;
identity.auth($scope.username, code, "totp").then((response) => {
$scope.success = true;
location.href = customization.plugins.core.loginredir || $routeParams.nextPage || '/';
location.href = customization.plugins.core.loginredir || $scope.sanitizeNextPage() || '/';
}, error => {
$event.code = "";
$log.log('Wrong TOTP', error);
Expand Down Expand Up @@ -54,7 +63,7 @@ angular.module('core').controller('CoreLoginController', function($scope, $log,
return
}
$scope.success = true;
location.href = customization.plugins.core.loginredir || $routeParams.nextPage || '/';
location.href = customization.plugins.core.loginredir || $scope.sanitizeNextPage() || '/';
}, error => {
$scope.working = false;
$log.log('Authentication failed', error);
Expand Down

0 comments on commit 230ecff

Please sign in to comment.