<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=WebFund_2024F_Lecture_16</id>
	<title>WebFund 2024F Lecture 16 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=WebFund_2024F_Lecture_16"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=WebFund_2024F_Lecture_16&amp;action=history"/>
	<updated>2026-04-22T14:38:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=WebFund_2024F_Lecture_16&amp;diff=24843&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture for November 12, 2024 is now available: * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.cc.vtt auto-generated captions]  ==Notes==  &lt;pre&gt; Lecture 16 ----------   - midterm is being graded, should hopefully be done by end of the week  - Assignment 2 should finally be uploaded later...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=WebFund_2024F_Lecture_16&amp;diff=24843&amp;oldid=prev"/>
		<updated>2024-11-12T22:59:33Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture for November 12, 2024 is now available: * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.cc.vtt auto-generated captions]  ==Notes==  &amp;lt;pre&amp;gt; Lecture 16 ----------   - midterm is being graded, should hopefully be done by end of the week  - Assignment 2 should finally be uploaded later...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture for November 12, 2024 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.m4v video]&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec16-20241112.cc.vtt auto-generated captions]&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 16&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
 - midterm is being graded, should hopefully be done by end of the week&lt;br /&gt;
 - Assignment 2 should finally be uploaded later today (sorry!)&lt;br /&gt;
&lt;br /&gt;
 - Q7 on A3: your analysis page should have 5 or 6 extra numbers, one per question (it is 5 or 6 depending on whether you are modifying your code with the extra question or not)&lt;br /&gt;
   Q3 has 5 blank submissions&lt;br /&gt;
   Q5 has 20 blank submissions&lt;br /&gt;
&lt;br /&gt;
Since you also report on the total number of submissions, with these stats you can see what fraction of students left a question blank&lt;br /&gt;
&lt;br /&gt;
--------------&lt;br /&gt;
&lt;br /&gt;
Today: cookies &amp;amp; TLS&lt;br /&gt;
&lt;br /&gt;
We previously discussed how http is a stateless protocol&lt;br /&gt;
&lt;br /&gt;
But sometimes we need state&lt;br /&gt;
 - most commonly, when we &amp;quot;log in&amp;quot; to a website&lt;br /&gt;
 - but is also used for site preferences (theme), other tasks&lt;br /&gt;
 - and of course, tracking for advertising targeting&lt;br /&gt;
&lt;br /&gt;
Most common mechanism for adding state to http is the &amp;quot;cookie&amp;quot; mechanism&lt;br /&gt;
&lt;br /&gt;
But what is a cookie?&lt;br /&gt;
 - data set by the server with a &amp;quot;Set-Cookie:&amp;quot; header&lt;br /&gt;
 - later requests to the server get the added header &amp;quot;Cookie: &amp;quot; with the value&lt;br /&gt;
   of the cookies that were previously set&lt;br /&gt;
 - allows the server to &amp;quot;save&amp;quot; data on the client (browser) that will be given back to it&lt;br /&gt;
    - remember, servers talk to many clients, so things like cookies&lt;br /&gt;
      help the server distinguish them from each other&lt;br /&gt;
&lt;br /&gt;
 - But remember, cookies are just data included in an HTTP header&lt;br /&gt;
    - so anyone can set any cookie&lt;br /&gt;
    - only way to be secure is to 1) make sure it isn&amp;#039;t sent to the wrong&lt;br /&gt;
      sites and 2) make sure it isn&amp;#039;t guessable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Web Server                    Browser&lt;br /&gt;
                 &amp;lt;---         GET /index.html&lt;br /&gt;
&lt;br /&gt;
contents of index.html  ----&amp;gt;   renders index.html, saves user=bob&lt;br /&gt;
 + Content-Type: text/html      cookie for this server&lt;br /&gt;
 + Set-Cookie: user=bob&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
                 &amp;lt;---         GET /index.html&lt;br /&gt;
		              + Cookies: user=bob&lt;br /&gt;
&lt;br /&gt;
contents of index.html  ---&amp;gt;   &lt;br /&gt;
  for the user bob&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any browser can set any cookie&lt;br /&gt;
 - if you can guess a cookie that allows you to get confidential information,&lt;br /&gt;
   that cookie is insecure (as is the web app)&lt;br /&gt;
 - if you can steal the cookie, you have some sort of hijacking attack&lt;br /&gt;
    - and can potentially be stolen by just impersonating the right site&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So why is it called cookie?&lt;br /&gt;
 - this is actually an old term&lt;br /&gt;
 - used by the X Window system, which predates the web&lt;br /&gt;
 - used as a general term for data stored that is opaque to the storer &amp;amp;&lt;br /&gt;
   used for authentication &amp;amp; session management&lt;br /&gt;
&lt;br /&gt;
Note that a browser has NO OBLIGATION to store a cookie for a website&lt;br /&gt;
 - it can forget it immediately&lt;br /&gt;
 - it can forget it later&lt;br /&gt;
&lt;br /&gt;
Browsers generally shouldn&amp;#039;t modify cookies, but they can easily forget them&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why is it a cookie?&lt;br /&gt;
 - I think someone was hungry&lt;br /&gt;
&lt;br /&gt;
What does it mean for a cookie to be secure?&lt;br /&gt;
 - that is separate from secure cookie handling, which needs other technology&lt;br /&gt;
 - essentially, the cookie should not be guessable by unauthorized parties&lt;br /&gt;
    - so if you have a cookie that represents that a user is logged in,&lt;br /&gt;
      unauthorized users shouldn&amp;#039;t be able to guess it, otherwise&lt;br /&gt;
      they can be logged in as well, even if they don&amp;#039;t know the password&lt;br /&gt;
&lt;br /&gt;
This is why you have to keep logging in on the web&lt;br /&gt;
 - everyone is paranoid about cookies being stolen, so they&lt;br /&gt;
   make them valid only for a limited period of time&lt;br /&gt;
&lt;br /&gt;
But remember, http is sent in the clear over the Internet&lt;br /&gt;
 - anyone could be snooping&lt;br /&gt;
 - and if they are listening in, they can grab any important cookies&lt;br /&gt;
   and use them for bad purposes&lt;br /&gt;
 - doesn&amp;#039;t matter if they are secure cookies or not!&lt;br /&gt;
&lt;br /&gt;
This is why almost all web traffic today is encrypted, using the protocol https&lt;br /&gt;
 - https is HTTP over TLS&lt;br /&gt;
 - TLS = transport layer security&lt;br /&gt;
 - used to be SSL = secure sockets layer&lt;br /&gt;
   - decided to have a more general name for a more general mechanism&lt;br /&gt;
&lt;br /&gt;
TLS can be used to secure any TCP/IP data stream&lt;br /&gt;
 - email (POP3, IMAP, SMTP) uses TLS today&lt;br /&gt;
 - basically any regular protocol can be put over TLS to make it &amp;quot;secure&amp;quot;&lt;br /&gt;
&lt;br /&gt;
But the security guarantees of TLS are very specific and have very strict requirements&lt;br /&gt;
&lt;br /&gt;
So if the assumptions of TLS hold, then you get&lt;br /&gt;
 - no eavesdropping (confidentiality)&lt;br /&gt;
    - even if traffic was recorded, can&amp;#039;t be decoded later even if both parties are compromised later (perfect forward secrecy)&lt;br /&gt;
 - no undedectable tampering (modifications just end communication with an error) (integrity)&lt;br /&gt;
 - one-sided or two-sided authentication&lt;br /&gt;
    - you either know who the server is, or you know who both the server &amp;amp; client are&lt;br /&gt;
    - on the web today we almost always do one-sided authentication&lt;br /&gt;
      (username/password/2FA are used for the other direction, not TLS)&lt;br /&gt;
&lt;br /&gt;
In TLS, entities are identified with certificates. A certificate has&lt;br /&gt;
 - the public key of the entity&lt;br /&gt;
 - associated metadata (name of organization/server, how long valid, etc.)&lt;br /&gt;
&lt;br /&gt;
In public key cryptography, you have public keys and private keys&lt;br /&gt;
 - public keys are given away&lt;br /&gt;
 - private keys must be private!&lt;br /&gt;
&lt;br /&gt;
A private key is used to decrypt or sign data&lt;br /&gt;
A public key is used to encrypt or verify signatures&lt;br /&gt;
&lt;br /&gt;
If you publish your public key&lt;br /&gt;
 - anyone can send you a secret message, but only you can read it&lt;br /&gt;
 - only you can sign a document as you, but anyone can verify that signature&lt;br /&gt;
&lt;br /&gt;
Digital signatures are cool because they say who signed it and that the document has not been modified at all&lt;br /&gt;
 - much better than signatures on paper!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>