fix: multiple vulnerabilities

This commit is contained in:
2026-06-17 21:43:41 -04:00
parent 6c810b07b7
commit 6a7b8653dc
15 changed files with 83 additions and 27 deletions
@@ -294,9 +294,9 @@ namespace SharpbinV3.Server.Controllers
)
return Unauthorized(new { success = false, message = "Invalid API key." });
if (paste.AuthorUUID != HttpContext.GetJwtUser()?.UUID)
if (paste.AuthorUUID == HttpContext.GetJwtUser()?.UUID)
return Ok(new { success = true, message = "View not recorded for author's own paste." });
if (paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() && paste.Visibility != 0)
if (paste.ExpiresAt != 0 && paste.ExpiresAt < DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() && paste.Visibility != 0)
return Ok(new { success = true, message = "View not recorded for expired paste." });
var result = await _pasteService.RecordView(paste, HttpContext);
@@ -124,10 +124,7 @@ namespace SharpbinV3.Server.Controllers
var actorIsAdmin = actorUser.Roles.HasFlag(Role.Admin);
var isSelfUpdate = targetUser.UUID == actorUser.UUID;
if (
(targetUser.Roles.HasFlag(Role.Admin) && !actorIsAdmin)
|| (!actorIsAdmin && !isSelfUpdate)
)
if ((targetUser.Roles.HasFlag(Role.Admin) && !actorIsAdmin) || (!actorIsAdmin && !isSelfUpdate))
return StatusCode(403, new { success = false, message = "You do not have permission to modify this user." });
if ((updatedUser.Roles.HasValue || updatedUser.IsBanned.HasValue) && !actorIsAdmin)