<div dir="ltr">Only the server should be generating the tokens, if the client knows the secret it can do whatever it wants.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 10, 2018 at 10:32 AM, anish10dec <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Let me explain the complete implementation methodology and problem<br>
statement<br>
<br>
URL to be protected<br>
<a href="http://site.media.com/mediafiles/movie.m3u8" rel="noreferrer" target="_blank">http://site.media.com/<wbr>mediafiles/movie.m3u8</a><br>
<br>
We are generating token on application/client side to send it along with<br>
request so that content is delivered by server only to authorized apps.<br>
<br>
Token Generation Methodology on App/Client<br>
<br>
expire = Current Epoch Time on App/Client + 600 ( 600 so that URL will be<br>
valid for 10 mins)<br>
uri = mediafiles/movie.m3u8<br>
secret = secretkey<br>
<br>
On Client , MD5 Function is used to generate token by using three above<br>
defined values<br>
token = MD5 Hash ( secret, uri, expire)<br>
<br>
Client passes generated token along with expiry time with URL<br>
<a href="http://site.media.com/mediafiles/movie.m3u8?token={generated" rel="noreferrer" target="_blank">http://site.media.com/<wbr>mediafiles/movie.m3u8?token={<wbr>generated</a><br>
value}&expire={value in variable expire}<br>
<br>
<br>
Token Validation on Server<br>
Token and Expire is captured and passed through secure link module<br>
<br>
location / {<br>
<br>
secure_link $arg_token,$arg_expire;<br>
secure_link_md5 "secretkey$uri$arg_expire";<br>
<br>
//If token generated here matches with token passed in request , content is<br>
delivered<br>
if ($secure_link = "") {return 405;} // token doesn't match<br>
<span class=""><br>
if ($secure_link = "0") {return 410;}<br>
</span>//If value in arg_expire time is greater current epoch time of server ,<br>
content is delivered .<br>
Since arg_expire has epoch time of device + 600 sec so on server it will be<br>
success. If someone tries to access the content using same URL after 600 sec<br>
, time on server will be greater than time send in arg_expire and thus<br>
request will be denied.<br>
<br>
<br>
Problem Statement<br>
Someone changes the time on his client device to say some future date and<br>
time. In this case same app will generate the token with above mention<br>
methodolgy on client and send it along with request to server.<br>
Server will generate the token at its end using all the values along with<br>
expire time send in URL request ( note here expire time is generated using<br>
future date on device)<br>
So token will match and 1st check will be successful .<br>
In 2nd check since arg_expire has epoch time of future date + 600 sec which<br>
will be obviously greater than current epcoh time of server and request<br>
will be successfully delivered.<br>
Anyone can use same token and extended epoch time with request for that<br>
period of time for which future date was set on device.<br>
<br>
Hopefully now its explainatory .<br>
Please let know if there is a way to protect the content in this scenario.<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,278063,278088#msg-278088" rel="noreferrer" target="_blank">https://forum.nginx.org/read.<wbr>php?2,278063,278088#msg-278088</a><br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br></div>