-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/843 revoke instance delegation2 #857
Conversation
string reasonPhrase = httpResponse.ReasonPhrase; | ||
_logger.LogError( | ||
"Writing of delegation policy at path: {policyPath} failed. Response Status Code:\n{status}. Response Reason Phrase:\n{reasonPhrase}", | ||
policyPath, |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to sanitize the policyPath
before logging it. Specifically, we should remove any newline characters from the policyPath
to prevent log forging. This can be done using the Replace
method to remove newline characters.
-
Copy modified line R95 -
Copy modified line R98
@@ -94,5 +94,6 @@ | ||
string reasonPhrase = httpResponse.ReasonPhrase; | ||
string sanitizedPolicyPath = policyPath.Replace("\n", "").Replace("\r", ""); | ||
_logger.LogError( | ||
"Writing of delegation policy at path: {policyPath} failed. Response Status Code:\n{status}. Response Reason Phrase:\n{reasonPhrase}", | ||
policyPath, | ||
sanitizedPolicyPath, | ||
status, |
bool validPath = DelegationHelper.TryGetDelegationPolicyPathFromInstanceRule(rules, out string path); | ||
if (validPath) | ||
{ | ||
_logger.LogError(ex, "An exception occured while processing authorization rules for delegation on delegation policy path: {path}", path); |
Check failure
Code scanning / CodeQL
Log entries created from user input High
user-provided value
This log entry depends on a
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to sanitize the path
variable before logging it. Since the log entries are plain text, we should remove any newline characters from the path
to prevent log forging. This can be done using the Replace
method to remove newline characters.
-
Copy modified line R303 -
Copy modified line R307 -
Copy modified lines R346-R347
@@ -302,2 +302,3 @@ | ||
{ | ||
string sanitizedPath = path.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogError( | ||
@@ -305,3 +306,3 @@ | ||
"An exception occured while processing authorization rules for delegation on delegation policy path: {path}", | ||
path); | ||
sanitizedPath); | ||
} | ||
@@ -344,3 +345,4 @@ | ||
{ | ||
_logger.LogError(ex, "An exception occured while processing authorization rules for delegation on delegation policy path: {path}", path); | ||
string sanitizedPath = path.Replace(Environment.NewLine, "").Replace("\n", "").Replace("\r", ""); | ||
_logger.LogError(ex, "An exception occured while processing authorization rules for delegation on delegation policy path: {path}", sanitizedPath); | ||
} |
Added Authorization removed for local test
src/Altinn.AccessManagement.Core/Models/AppsInstanceRevokeResponse.cs
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
Description
Related Issue(s)
Developer/Reviewer Checklist
Documentation