<?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_21</id>
	<title>WebFund 2024F Lecture 21 - 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_21"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=WebFund_2024F_Lecture_21&amp;action=history"/>
	<updated>2026-06-02T19:50:48Z</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_21&amp;diff=24903&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture for November 28, 2024 is now available: * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.cc.vtt auto-generated captions]  ==Notes==  &lt;pre&gt; Lecture 21 ----------  Web Security  What are the goals of computer security?  - confidentiality, integrity, availability (CIA)  - (entity authe...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=WebFund_2024F_Lecture_21&amp;diff=24903&amp;oldid=prev"/>
		<updated>2024-11-28T19:29:00Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture for November 28, 2024 is now available: * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.cc.vtt auto-generated captions]  ==Notes==  &amp;lt;pre&amp;gt; Lecture 21 ----------  Web Security  What are the goals of computer security?  - confidentiality, integrity, availability (CIA)  - (entity authe...&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 28, 2024 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.m4v video]&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec21-20241128.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 21&lt;br /&gt;
----------&lt;br /&gt;
&lt;br /&gt;
Web Security&lt;br /&gt;
&lt;br /&gt;
What are the goals of computer security?&lt;br /&gt;
 - confidentiality, integrity, availability (CIA)&lt;br /&gt;
 - (entity authentication)&lt;br /&gt;
&lt;br /&gt;
What does this mean in the context of web applications?&lt;br /&gt;
 - make sure web apps stay up (keep running)  &amp;lt;-- availability&lt;br /&gt;
 - ensure data stored in a web app isn&amp;#039;t corrupted &amp;lt;-- integrity&lt;br /&gt;
 - ensure data and services are only provided to authorized entities &amp;lt;--- confidentiality&lt;br /&gt;
&lt;br /&gt;
What have we done mostly right wrt security?&lt;br /&gt;
 - secure password storage&lt;br /&gt;
 - sessions with expiration and strong session IDs&lt;br /&gt;
 - proper parameterization of database queries (avoiding SQL injection vulnerabilities)&lt;br /&gt;
&lt;br /&gt;
What is SQL injection?&lt;br /&gt;
 - attacker is able to execute arbitrary SQL queries by &amp;quot;injecting&amp;quot; malicious inputs to the application&lt;br /&gt;
&lt;br /&gt;
Approaches to avoiding SQL injection is to sanitize inputs&lt;br /&gt;
 - escape/quote characters like &amp;quot;;&amp;quot;&lt;br /&gt;
    - this is very hard to do in general, very error prone&lt;br /&gt;
 - separate definition of SQL command from user inputs&lt;br /&gt;
    - this is much better, very safe&lt;br /&gt;
    - done right, no way for attacker to turn malicious input into SQL code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SQL injection is just one example of the general class of code injection attacks&lt;br /&gt;
 - attacker provides input to an application that is meant to be treated as data&lt;br /&gt;
   but gets interpreted as code, typically running in a privileged context&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Classic examples of code injection are buffer overflow attacks&lt;br /&gt;
  - typically in C code, but can come up in any code that uses a C library&lt;br /&gt;
  - C by default doesn&amp;#039;t do proper bounds checking on arrays&lt;br /&gt;
     - very easy to write data outside the bounds of an array&lt;br /&gt;
  - if you know how memory is laid out, you can overwrite key bits of data&lt;br /&gt;
    (pointers, esp return stack pointer) that then allow an attacker to take over the program,&lt;br /&gt;
    control how it executes&lt;br /&gt;
    &lt;br /&gt;
Modern systems have many defenses against buffer overflow and related memory corruption attacks&lt;br /&gt;
 - stack canaries&lt;br /&gt;
 - ASLR (address space layout randomization)&lt;br /&gt;
 - no-execute memory&lt;br /&gt;
&lt;br /&gt;
Web code is mostly written in languages that automatically manage memory&lt;br /&gt;
 - so there isn&amp;#039;t much opportunity for memory corruption attacks&lt;br /&gt;
 - however, there are MANY opportunities for code injection attacks, they just use different code!&lt;br /&gt;
&lt;br /&gt;
Wherever you have a code execution engine, you have an opportunity for code injection.&lt;br /&gt;
&lt;br /&gt;
Where do we have code execution engines?&lt;br /&gt;
 - client-side JavaScript, HTML, CSS, WebAssembly&lt;br /&gt;
 - server-side JavaScript (or whatever other language is running)&lt;br /&gt;
 - server-side SQL&lt;br /&gt;
&lt;br /&gt;
code injection vulnerabilities in server-side SQL are common (SQL Injection)&lt;br /&gt;
code injection vulns in server-side JavaScript are rare (require use of eval mostly)&lt;br /&gt;
  - i.e., construct a string and then run it as JavaScript code&lt;br /&gt;
  - was much bigger of an issue when JSON parsing was done using regular JavaScript&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
client-side code is VERY vulnerable to code injection attacks because &amp;quot;code&amp;quot; is dynamically constructed and naturally co-exists with untrustworthy data&lt;br /&gt;
&lt;br /&gt;
cross-site scripting attacks (XSS) are a well-known class of web application vulns&lt;br /&gt;
 - but XSS attacks don&amp;#039;t have to be cross-site and don&amp;#039;t have to involve scripting!&lt;br /&gt;
 - better thought of as code injection attacks at the level of HTML/CSS/JavaScript&lt;br /&gt;
   - but with a server component&lt;br /&gt;
&lt;br /&gt;
The classic template for XSS:&lt;br /&gt;
 * a malicious user uploads content to a web server&lt;br /&gt;
 * victim accesses web app and is compromised&lt;br /&gt;
&lt;br /&gt;
Vuln arises because attacker can send malicious data to their target VIA THE WEB SERVER&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In authdemo2, how could we potentially perform an XSS attack?&lt;br /&gt;
 - student could upload an assignment with embedded HTML/CSS/JavaScript&lt;br /&gt;
 - when instructor/admin views submissions (/list), the malicious payload executes&lt;br /&gt;
    - maybe sends all submissions to attacker?&lt;br /&gt;
&lt;br /&gt;
How do you mitigate vulnerabilities in client-side code?&lt;br /&gt;
 - filter &amp;lt;--- make sure untrusted input fits a safe pattern&lt;br /&gt;
               (e.g., student IDs are all numeric digits)&lt;br /&gt;
 - escape &amp;lt;--- transform characters that could allow code to be injected into safe forms&lt;br /&gt;
&lt;br /&gt;
To prevent HTML from being inserted, you have to prevent tags from being inserted&lt;br /&gt;
 - and tags are formed using &amp;lt;&amp;gt;&lt;br /&gt;
 - so you replace &amp;lt; with &amp;amp;lt; and &amp;gt; with &amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>