mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +00:00
[1.6.x] 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.
Backport of 7fe5b656c9 from master
This commit is contained in:
@@ -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
|
||||
@@ -332,6 +333,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
|
||||
|
||||
Reference in New Issue
Block a user