List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] Encode value and field before calculating cookie digest, the same way secure_value() does
@ 2018-04-12 17:54 thevlad
  2018-06-16 16:28 ` john
  0 siblings, 1 reply; 3+ messages in thread
From: thevlad @ 2018-04-12 17:54 UTC (permalink / raw)


From: Vlad Safronov <thevlad at gmail.com>

Bugfix: Encode value and field before calculating cookie digest, the same way as secure_value() does
so validating will work correctly on encoded values.
---
 filters/simple-authentication.lua | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/filters/simple-authentication.lua b/filters/simple-authentication.lua
index de34d09..b40a819 100644
--- a/filters/simple-authentication.lua
+++ b/filters/simple-authentication.lua
@@ -230,6 +230,8 @@ function validate_value(expected_field, cookie)
 		return nil
 	end
 
+	value = url_encode(value)
+	field = url_encode(field)
 	-- Lua hashes strings, so these comparisons are time invariant.
 	if hmac ~= crypto.hmac.digest("sha1", field .. "|" .. value .. "|" .. tostring(expiration) .. "|" .. salt, secret) then
 		return nil
-- 
2.17.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-17 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 17:54 [PATCH] Encode value and field before calculating cookie digest, the same way secure_value() does thevlad
2018-06-16 16:28 ` john
     [not found]   ` <CALR6X0_NbTSKE0DPDoni7H6M6d1HoXco=PBCJQRQOeVZGaGwZw@mail.gmail.com>
     [not found]     ` <20180617175023.GM1922@john.keeping.me.uk>
2018-06-17 19:03       ` thevlad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).