Skip to content

Commit 09f56bd

Browse files
authored
Merge pull request #22 from Demindiro/security-fixes
2 parents 9b63006 + a372d7d commit 09f56bd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SQLITE = sqlite3
44

55
default: venv
66

7-
test:: venv
7+
test: venv
88
test/all.sh
99

1010
venv:
@@ -13,3 +13,5 @@ venv:
1313

1414
forum.db:
1515
$(SQLITE) $@ < schema.txt
16+
17+
.PHONY: test

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
app = Flask(__name__)
1515
db = DB(os.getenv('DB'))
1616

17+
# This defaults to None, which allows CSRF attacks in FireFox
18+
# and older versions of Chrome.
19+
# 'Lax' is sufficient to prevent malicious POST requests.
20+
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
21+
1722
class Config:
1823
pass
1924
config = Config()
@@ -28,6 +33,13 @@ class Role:
2833
MODERATOR = 1
2934
ADMIN = 2
3035

36+
@app.after_request
37+
def after_request(response):
38+
# This forbids other sites from embedding this site in an iframe,
39+
# preventing clickjacking attacks.
40+
response.headers['X-Frame-Options'] = 'DENY'
41+
return response
42+
3143
@app.route('/')
3244
def index():
3345
return render_template(

0 commit comments

Comments
 (0)