1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-09 20:03:47 -05:00

use fixed-time comparison of secrets (#1698)

This commit is contained in:
Kyle Spearrin
2021-11-08 15:55:42 -05:00
committed by GitHub
parent c07794e907
commit 7cc7b84eaf
8 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,5 @@
using Bit.Core;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -34,7 +35,7 @@ namespace Bit.Billing.Controllers
var key = HttpContext.Request.Query.ContainsKey("key") ?
HttpContext.Request.Query["key"].ToString() : null;
if (key != _billingSettings.AppleWebhookKey)
if (!CoreHelpers.FixedTimeEquals(key, _billingSettings.AppleWebhookKey))
{
return new BadRequestResult();
}

View File

@ -49,7 +49,7 @@ namespace Bit.Billing.Controllers
[HttpPost("ipn")]
public async Task<IActionResult> PostIpn([FromBody] BitPayEventModel model, [FromQuery] string key)
{
if (key != _billingSettings.BitPayWebhookKey)
if (!CoreHelpers.FixedTimeEquals(key, _billingSettings.BitPayWebhookKey))
{
return new BadRequestResult();
}

View File

@ -14,6 +14,7 @@ using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Billing.Controllers
{
@ -57,7 +58,7 @@ namespace Bit.Billing.Controllers
var key = HttpContext.Request.Query.ContainsKey("key") ?
HttpContext.Request.Query["key"].ToString() : null;
if (key != _billingSettings.FreshdeskWebhookKey)
if (!CoreHelpers.FixedTimeEquals(key, _billingSettings.FreshdeskWebhookKey))
{
return new BadRequestResult();
}

View File

@ -3,6 +3,7 @@ using Bit.Core.Enums;
using Bit.Core.Models.Table;
using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -56,7 +57,7 @@ namespace Bit.Billing.Controllers
var key = HttpContext.Request.Query.ContainsKey("key") ?
HttpContext.Request.Query["key"].ToString() : null;
if (key != _billingSettings.PayPal.WebhookKey)
if (!CoreHelpers.FixedTimeEquals(key, _billingSettings.PayPal.WebhookKey))
{
_logger.LogWarning("PayPal webhook key is incorrect or does not exist.");
return new BadRequestResult();

View File

@ -80,7 +80,7 @@ namespace Bit.Billing.Controllers
[HttpPost("webhook")]
public async Task<IActionResult> PostWebhook([FromQuery] string key)
{
if (key != _billingSettings.StripeWebhookKey)
if (!CoreHelpers.FixedTimeEquals(key, _billingSettings.StripeWebhookKey))
{
return new BadRequestResult();
}