Skip to content

Add admin permission check for project restore from backup#3695

Merged
fiftin merged 3 commits intosemaphoreui:developfrom
JulianKap:fix/permission-check-for-project-restore
Mar 24, 2026
Merged

Add admin permission check for project restore from backup#3695
fiftin merged 3 commits intosemaphoreui:developfrom
JulianKap:fix/permission-check-for-project-restore

Conversation

@JulianKap
Copy link
Copy Markdown
Contributor

PR Title

Add admin permission check for project restore from backup

Description

This PR adds a missing admin permission check when restoring a project from backup.

Problem

In the current implementation, creating a new project correctly requires admin privileges.
However, the project restore from backup endpoint did not perform the same permission check.

As a result, a non-admin user could restore a project from a backup and effectively create a new project without having the required permissions.

This created a permission bypass scenario:

  • non-admin users cannot create projects directly
  • but they could restore a project from backup, which results in a new project being created

Solution

This PR adds the same admin permission validation used in project creation to the project restore operation.

Now:

  • only users with admin privileges can restore a project from backup
  • permission checks are consistent with the normal project creation flow

Result

  • Prevents permission bypass via project restore

user := helpers.GetFromContext(r, "user").(*db.User)

if !user.Admin && !util.Config.NonAdminCanCreateProject {
log.Warn(user.Username + " is not permitted to edit users")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this message incorrect

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fiftin , I updated the message text in the log.

@fiftin fiftin merged commit 55422e0 into semaphoreui:develop Mar 24, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants