Skip to content
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

Add validation for alias #1418

Closed
anthonyfok opened this issue Sep 10, 2015 · 3 comments
Closed

Add validation for alias #1418

anthonyfok opened this issue Sep 10, 2015 · 3 comments
Assignees
Milestone

Comments

@anthonyfok
Copy link
Member

Following some tests related to the discussions at Issue #701, I came to realize that Hugo would happily create aliases (redirections) outside of the public/ directory if a content page contains aliases that traverse up parent directories. For example:

aliases = [ "/some-page/", "../some-page-2/", "../../some-page-3/" ]

After a Hugo run, some-page-2/ would be created in the same parent directory as public/, whereas some-page-3/index.html would be created outside of the web site source directory altogether.

At least Hugo v0.13, v0.14, as well as the current HEAD are affected. (I did not test v0.12.)

@bep
Copy link
Member

bep commented Sep 10, 2015

But this

  • is still is the user him or herself who does this?
  • still needs a web server that travels outside the content root, and even then it is to your own content ...

It needs some validation, but I'm not sure about the "High Priority".

@anthonyfok
Copy link
Member Author

What I worry is a scenario where a naïve user tries out a sample Hugo-based website that he/she downloads from somewhere, and then blindly tries to build it with Hugo...

Worse, he/she runs Hugo as root...

Granted, the chances of that happening are slim, and probably a malicious attacker could only create/overwrite certain index.html or other randomly-named.html on the system.

So, I think it would qualify as a security issue, though probably not a "High Priority" one, so I have removed that label.

@bep bep changed the title [Security] Aliases can be created outside of the public/ directory Add validation for alias Sep 10, 2015
@anthonyfok anthonyfok self-assigned this Sep 13, 2015
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 13, 2015
Add validation before creating aliases:

 * Prevent creating aliases outside webroot (public/ dir)
 * Skip empty "" alias
 * Skip "/" → "/index.html", which gets overwritten anyway
 * Refuse to create Windows-invalid filenames on Windows;
   warn on other platforms
 * In case of invalid aliases, after skipping them,
   return `err = nil` to prevent the error passing up
   all the way to `hugolib.Render()` and causing Hugo to abort.
 * Update alias tests.

Fixes #701: Add support for alias with whitespace
Fixes gohugoio#1418: Add validation for alias
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
Add validation before creating aliases:

 * Prevent creating aliases outside webroot (public/ dir)
 * Skip empty "" alias
 * Skip "/" → "/index.html", which gets overwritten anyway
 * Refuse to create Windows-invalid filenames on Windows;
   warn on other platforms
 * In case of invalid aliases, after skipping them,
   return `err = nil` to prevent the error passing up
   all the way to `hugolib.Render()` and causing Hugo to abort.
 * Update alias tests.

Fixes gohugoio#701: Add support for alias with whitespace
Fixes gohugoio#1418: Add validation for alias
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
Add validation before creating aliases:

 * Prevent creating aliases outside webroot (public/ dir)
 * Skip empty "" alias
 * Skip "/" → "/index.html", which gets overwritten anyway
 * Refuse to create Windows-invalid filenames on Windows;
   warn on other platforms
 * In case of invalid aliases, after skipping them,
   return `err = nil` to prevent the error passing up
   all the way to `hugolib.Render()` and causing Hugo to abort.
 * Update alias tests.

Fixes gohugoio#701: Add support for alias with whitespace
Fixes gohugoio#1418: Add validation for alias
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants