-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
promote #751
Conversation
Diam 56 admin
try net 9 build
nuget and net 9 changes
install mono
Bcpsdems 2201 delegate access
response.ResponseData.Add("delegateRequestId", "" + newRequest.RequestId); | ||
|
||
var msgId = Guid.NewGuid(); | ||
logger.LogInformation($"Sending notification to {lawyerParty.Email} for new delgate request {requestor.Email} [{command.StagingRequestId}]"); |
Check warning
Code scanning / CodeQL
Exposure of private information Medium
access to local variable email
Private data returned by
access to local variable email
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we should avoid logging sensitive information such as email addresses. Instead, we can log less sensitive information or use anonymized data. In this case, we can remove the email addresses from the log message and replace them with anonymized identifiers or other non-sensitive information.
- Remove the email addresses from the log message on line 86 in
SubmitDelegateRequest.cs
. - Ensure that the log message still provides useful information for debugging or auditing purposes without exposing private data.
-
Copy modified line R86
@@ -85,3 +85,3 @@ | ||
var msgId = Guid.NewGuid(); | ||
logger.LogInformation($"Sending notification to {lawyerParty.Email} for new delgate request {requestor.Email} [{command.StagingRequestId}]"); | ||
logger.LogInformation($"Sending notification for new delegate request from party {requestor.Id} to lawyer party {lawyerParty.Id} [{command.StagingRequestId}]"); | ||
// send a notification to the defense counsel that they have a pending request |
response.ResponseData.Add("delegateRequestId", "" + newRequest.RequestId); | ||
|
||
var msgId = Guid.NewGuid(); | ||
logger.LogInformation($"Sending notification to {lawyerParty.Email} for new delgate request {requestor.Email} [{command.StagingRequestId}]"); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to sanitize the user input before logging it. Specifically, we should remove any new line characters from the email addresses and other user-provided values to prevent log forging. This can be done using the String.Replace
method to replace new line characters with an empty string.
-
Copy modified lines R86-R89
@@ -85,3 +85,6 @@ | ||
var msgId = Guid.NewGuid(); | ||
logger.LogInformation($"Sending notification to {lawyerParty.Email} for new delgate request {requestor.Email} [{command.StagingRequestId}]"); | ||
var sanitizedLawyerEmail = lawyerParty.Email.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
var sanitizedRequestorEmail = requestor.Email.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
var sanitizedStagingRequestId = command.StagingRequestId.ToString().Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
logger.LogInformation($"Sending notification to {sanitizedLawyerEmail} for new delgate request {sanitizedRequestorEmail} [{sanitizedStagingRequestId}]"); | ||
// send a notification to the defense counsel that they have a pending request |
Party = requestor, | ||
LawyerPartyId = lawyer.Id | ||
}); | ||
logger.LogInformation($"Storing staging for {requestor.FirstName} {requestor.LastName} to delegate to {lawyer.FirstName} {lawyer.LastName} with id {stagingGuid.ToString()}"); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to sanitize the user input before logging it. Since the log entries are plain text, we should remove any new line characters from the user input to prevent log forging. This can be done using the String.Replace
method to replace new line characters with an empty string.
We will modify the log message on line 72 in the file backend/webapi/Features/DelegateAccess/Query/DelegateAccessValidationQuery.cs
to sanitize the requestor.FirstName
and requestor.LastName
values before logging them.
-
Copy modified lines R72-R74
@@ -71,3 +71,5 @@ | ||
}); | ||
logger.LogInformation($"Storing staging for {requestor.FirstName} {requestor.LastName} to delegate to {lawyer.FirstName} {lawyer.LastName} with id {stagingGuid.ToString()}"); | ||
var sanitizedFirstName = requestor.FirstName.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
var sanitizedLastName = requestor.LastName.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
logger.LogInformation($"Storing staging for {sanitizedFirstName} {sanitizedLastName} to delegate to {lawyer.FirstName} {lawyer.LastName} with id {stagingGuid.ToString()}"); | ||
|
} | ||
else | ||
{ | ||
logger.LogError($"Failed to store staging record for {requestor.FirstName} {requestor.LastName} to delegate to {lawyer.FirstName} {lawyer.LastName}"); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 9 days ago
To fix the problem, we need to sanitize the user input before logging it. Specifically, we should remove any new line characters from the user-provided values (requestor.FirstName
and requestor.LastName
) to prevent log forging attacks. This can be achieved using the String.Replace
method to replace new line characters with an empty string.
-
Copy modified line R72 -
Copy modified line R82
@@ -71,3 +71,3 @@ | ||
}); | ||
logger.LogInformation($"Storing staging for {requestor.FirstName} {requestor.LastName} to delegate to {lawyer.FirstName} {lawyer.LastName} with id {stagingGuid.ToString()}"); | ||
logger.LogInformation($"Storing staging for {requestor.FirstName.Replace(Environment.NewLine, "")} {requestor.LastName.Replace(Environment.NewLine, "")} to delegate to {lawyer.FirstName.Replace(Environment.NewLine, "")} {lawyer.LastName.Replace(Environment.NewLine, "")} with id {stagingGuid.ToString()}"); | ||
|
||
@@ -81,3 +81,3 @@ | ||
{ | ||
logger.LogError($"Failed to store staging record for {requestor.FirstName} {requestor.LastName} to delegate to {lawyer.FirstName} {lawyer.LastName}"); | ||
logger.LogError($"Failed to store staging record for {requestor.FirstName.Replace(Environment.NewLine, "")} {requestor.LastName.Replace(Environment.NewLine, "")} to delegate to {lawyer.FirstName.Replace(Environment.NewLine, "")} {lawyer.LastName.Replace(Environment.NewLine, "")}"); | ||
throw new AccessRequestException($"Failed to store staging record"); |
No description provided.