Skip to content

Commit

Permalink
Restrict SaveJSONFile() to the Grafana\public folder
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCWills committed Dec 10, 2024
1 parent 59ef0d2 commit 219bc28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Applications/openHistorian/openHistorian/DataHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ public bool CheckIfUpdateCOMTRADECountersIsCompleted(uint operationHandle) =>
/// <returns>URL to download filename.</returns>
public string SaveJSONFile(string targetFilePath, string json)
{
string localPath = FilePath.GetAbsolutePath("");
string localPath = FilePath.GetAbsolutePath(@"Grafana\public");
targetFilePath = FilePath.GetAbsolutePath(targetFilePath);

// Prevent file saves outside local file path
if (!targetFilePath.StartsWith(localPath))
if (!targetFilePath.StartsWith(localPath, StringComparison.OrdinalIgnoreCase))
throw new SecurityException("Path access error: Cannot save JSON file outside local file path.");

// Prevent saving data that is not valid JSON (helps prevent possible function abuse)
Expand Down

0 comments on commit 219bc28

Please sign in to comment.