mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-11 19:35:32 +00:00
Merge pull request #1155 from keymanapp/developer-web-editor-security-backend
[Developer] Prevent web requests from breaking out of our root path with ../
This commit is contained in:
commit
68154be506
2 changed files with 9 additions and 2 deletions
|
|
@ -262,9 +262,9 @@ begin
|
|||
end
|
||||
else
|
||||
begin
|
||||
if Pos('..', doc) > 0 then
|
||||
if IncludesParentFolderReference(doc) then
|
||||
begin
|
||||
// TODO: This is a naive security check. Need to expand
|
||||
// Block paths that attempt to break out of our 'root'
|
||||
Respond404(AContext, ARequestInfo, AResponseInfo);
|
||||
end
|
||||
else
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ uses
|
|||
type
|
||||
TBaseHttpResponder = class
|
||||
protected
|
||||
function IncludesParentFolderReference(const path: string): Boolean;
|
||||
procedure RespondFile(AFileName: string; AContext: TIdContext;
|
||||
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
|
||||
procedure Respond404(AContext: TIdContext;
|
||||
|
|
@ -25,6 +26,12 @@ uses
|
|||
|
||||
{ TBaseHttpResponder }
|
||||
|
||||
function TBaseHttpResponder.IncludesParentFolderReference(
|
||||
const path: string): Boolean;
|
||||
begin
|
||||
Result := path.Contains('../') or path.Contains('..\');
|
||||
end;
|
||||
|
||||
procedure TBaseHttpResponder.Respond404(
|
||||
AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
|
||||
AResponseInfo: TIdHTTPResponseInfo);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue