1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

Prevented arbitrary file inclusion with {% ssi %} tag and relative paths.

Thanks Rainer Koirikivi for the report and draft patch.

This is a security fix; disclosure to follow shortly.
This commit is contained in:
Tim Graham
2013-08-27 18:50:11 -04:00
parent 1278ee3ca7
commit 7fe5b656c9
2 changed files with 33 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
"""Default tags used by the template system, available to all templates."""
from __future__ import unicode_literals
import os
import sys
import re
from datetime import datetime
@@ -328,6 +329,7 @@ class RegroupNode(Node):
return ''
def include_is_allowed(filepath):
filepath = os.path.abspath(filepath)
for root in settings.ALLOWED_INCLUDE_ROOTS:
if filepath.startswith(root):
return True