Skip to content

Instantly share code, notes, and snippets.

@RaulTsc
Last active June 6, 2017 12:38
Show Gist options
  • Save RaulTsc/83148a245fa1571e2b18c548524b5017 to your computer and use it in GitHub Desktop.
Save RaulTsc/83148a245fa1571e2b18c548524b5017 to your computer and use it in GitHub Desktop.
  • C8 + C9
  • C7 (RSA, El-Gammal, DH, AES)
  • One time passwords
  1. Saltzer & Schroeder

  • Open design - Assume the attackers have the sources and the specs.
  • Fail-safe defaults - Fail closed; no single point of failure. Fail by default.
  • Least privilege - No more privileges than what is needed.
  • Economy of mechanism - Keep it simple, stupid.
  • Separation of privileges - Don’t permit an operation based on a single condition.
  • Total mediation - Check everything, every time.
  • Least common mechanism - Beware of shared resources.
  • Psychological acceptability - Will they use it?
  1. Return to libc + pointer overwrite

  • Return to libc:

    • A return-into-libc attack does not cause the attacked process to return directly to shellcode and execute shellcode on the stack
    • It makes it return to a libc function address (must know the address)
    • It causes the process to return, one by one, to a chain of library functions
    • They can directly perform the operations the attacker wants or they can be used to execute shellcode
  • Pointer overwrite

    • Can overwrite: function pointers, user functions, pointers to library functions, pointers to data
    • Attacks might be in two steps: a buffer overflow overwrites a pointer. Later, this is used to overwrite critical area (retaddress, PLT etc)
  1. Race conditions (script level + file)

  • Race condition: when the result of an operation can be different based on the order of the processes are executed/scheduled or the order in which competing instructions are executed.
  • Old UNIX login attack (press ESC repeatedly to gain root access)
  • Typically race conditions happen on opening/validating files, running subprograms
  1. Environment variables (why it is important to control execution environment)

  • If an attacker modifies env variables and they are used in a program without validating them(i.e not checking their size when copying them), the attacker might be able to overflow the associated buffer.
  • So if size/content of environment variables are not checked and they can be modified by an attacker, they can insert malicious (i.e shellcode) into the stack.
  • Overwrite PATH so it executes our sh
  • Can overwrite params separator (default ' ', but can be anything)
  1. Explain the principle behind cookies -- for SYN cookies and for the browser.

  • SYN cookies
    • SYN cookies are particular choices of initial TCP sequence numbers by TCP servers
    • SYN cookies is a technique used to resist SYN flood attacks
    • In particular, the use of SYN cookies allows the server to avoid dropping connections when the SYN queue fills up
    • The server sends back the SYN+ACK response to the client but discards the SYN package
    • If the server receives back an ACK from the client, it is able to reconstruct the SYN package using information encoded in the TCP sequence number
    • SYN flooding leave the server with a lot of half-open connections
    • Basically, the server removes the SYN packet from the queue and then later if it receives an ACK packet, it checks that the secret function works for a recent value of t and if so, it rebuilds the SYN queue later from the encoded MSS.
  • Browser cookies
    • Small bits of information websites store on your computer
    • They are used to keep state (login, preferences etc). I.e you are on a website example.com which shows/hides an element if you click some button. If you hide & reload the page (or view it later at any point), it can use cookies to remember the state of the element and display/hide it.
    • Websites are only allowed to see their own cookies
    • Bad uses: a company can use cookies to track you across the web and possibly target ads. The company can see you looked on olx.com at watches so next time you're on some news site it will show you ads about watches.
  1. Explain attacks by faking a source address and the countermeasures against them.

  • SYN flooding
    • Syn flooding is a denial of service attack where an attacker can send a lot of SYN packages from random sources (might be real or not), the server will respond with SYN-ACK but even if the sources are real, they won't respond with an ACK because they don't know they initiated a connection. So the server is left with a lot of half-open connections, the SYN queue fills up, and at some point it will no longer accept connections.
    • Possible bad solution: enlarge SYN queue. Does not really fix the problem, just makes it harder. Good solutions: SYN cookies, Firewalls, Filtering.
  1. Is Network Address Translation useful for security? Why/how?

  • Yes. It restricts the number of public ip addresses and allows for stricter control of resources on both sides of the firewall.
  • It is the process where a network device, usually the firewall, assigns a public ip address to a machine inside a private network. Usually, all the machines in the private network have the same public ip.
  • Used to conserve IPv4 address space.
  1. Explain the main types of cross-site attacks in a browser.

  • Cross-site Request Forgery (XSRF)
    • Third-party, malicious sites can initiate HTTP requests to a web app on an user's behalf without his knowledge
    • The attacker exploits the trust a web app has against the user's browser
    • Assume victim is authenticated in the web app(the browser has a valid cookie), the attacker can include a link or a script in a third-party web app that the victim visits. This can then make HTTP requests to the web app and the server has no idea if it is a real request or a malicious one.
    • Ex: Password change feature. Hacker site could execute a script to send a fake password-change request on an users behalf to the web app, which is authenticated by the browser, and the server cannot know it is an attack.
    • Protection: CORS, XSRF tokens, checking origin, referer headers. Hope browsers obey same-origin policy.
  • Cross-site Script Inclusion (XSSI)
    • An user goes to website A which uses a script from domain B which contains sensitive data. He has to be authenticated in both.
    • Attacker has website C which also loads script from B (user is authenticated in B), so they can steal the sensitive data (same execution context -- website C, can steal global variables, global functions data from B).
  • Cross-site Scripting (XSS)
    • Malicious users of an web application can send malicious code to a different end user through the web app (i.e comments on facebook). User X adds a comment that has a hidden javascript method that makes a XHR with the user's cookies to a web server.
    • Protection: Sanitize/encode inputs (never trust user input)
  1. Give 3 security principles/rules regarding cipthertexts.

  2. Difference between hash functions / crypto.

  • Hash functions: one-way functions, crypto: two-way functions.
  • Can decrypt encrypted message, cannot 'unhash' a hashed message.
  1. Sketch Block chain encrypting scheme

  1. Difference between dictionary attack and precomputed. Why is salt effective/important? (what is precomputed?)

  • Dictionary vs brute force attacks
    • Brute force: better coverage, it covers all possible values. Takes a long time to complete. Advanced brute force attacks might use patterns (capital letters are usually at the start, only 1 or 2 digits etc)
    • Dictionary: faster time. Uses a set of precomputed values in order to guess the password.
  1. Define RSA. Why is small e good? Why it is bad and how to fix it?

  • C7 + C8
  1. ElGamal and Diffie-Hellman.

  • Diffie-Hellman

    • Key-exchange protocol
    • Typically used in symmetric encryption schemes
    • Vulnerable to MITM attacks
  • ElGamal

    • Public key encryption protocol
  • Q: Can we add more details about how they work here?
  • C7 + C8
  1. Fair exchange with/without trusted third party.

  • Q: What is this?
  • C10 (primele 2)
  1. Protocol problem.. find what components are missing from a message/ what types of attacks can appear.

  • Usual problems:
    • Lack of freshness (the attacker can intercept a message send it again later). Solution: add "nonces" (number used once), i.e random numbers (uniqueness) or timestamps (uniqueness + freshness)
    • Lack of authentication (the attacker can pretend to be someone else). Solution: challenge and wait for response, usage of private + public key encryption
  • Usual attacks: man-in-the-middle, reflection attacks, reply attacks
  1. What policies and mechanisms would you use to avoid virus infection on a system?

  • Have a quality antivirus
  • Disable autorun feature on windows
  • Have a good firewall
  1. Is filtering packets exiting the local network useful? Why (not)?

  2. Explain role-based access control and multilevel security.

  • Role-based access control

    • It is an approach to restricting system access to authorised users
    • Policy neutral control mechanism defined around roles/privileges
    • Role user can do X, Y. Role admin-user can do U, Z.
    • There can be the case that role admin-user is included in role user (admin-user can do U,Z,X,Y).
    • Currently using this in a web app. OAuth 2.0 scopes. 5 roles atm: Superadmin_all, company_admin, company_user, tenant, public.
  • Multilevel security

    • Allow acce only to the ones authorised for it.
    • Ex: In a military base door system, a general has access everywhere but a simple soldier only has access to 30% of the doors.
  1. Explain how setuid and seteuid differ. Why is either one not enough?

  • Q: What is setuid,seteuid and how do they differ?
  1. Explain the buffer overflow protection schemes implemented by the compiler.

  • Use of canaries (placed near the buffer on the stack. If overwritten => buffer overflow)
    • Terminator canaries (CR,LF,-1. Used to protect against strcpy vulnerabilities)
    • Random canaries (Randomly generated value known only by defense mechanism. Hard to bypass, attacker needs to read from stack)
    • XOR canaries (Randomly generated value XORd with control data. Harder to bypass than random canaries, but still doable)
  • Bounds checking -- add runtime bounds for each allocated memory block and check pointers against that.
  • Tagging
  1. Detail examples of insecure C function use and their replacements.

  • gets (removed in C11)
  • strcpy -> strncpy
  • strcat -> strncat
  1. Describe attacks on a program by controling its environment and any protections.

  • Can override PATH
  • Can put executable in same folder so it takes it (eg sh)
  • Changing whitespace separator
  • Protection: Check directory owner (in some cases, if root => ok (/bin owner root => exec sh), current dir owner != root => don't exec)
  1. Setuid -- confused deputy.

  • A confused deputy is a program that is fooled by a third party program to misuse its authority.

  • Q: How does it relate to setuid ?

  1. Kaminsky attack

  • When resolving a domain name, the computer's dns server either has it cached or asks for it. The DNS server creates a 16bit token to make sure the request is relevant. The DNS server can then be flooded with replies and if we guess the 16bit token (65363 posibilities), we've successfully poisoned the dns. This was regarded as highly unlikely as the TTL was very long so only one request per day/few days could be made. But that is not true for sibling domains (aaa.google.com, aab.google.com). Dan Kaminsky demonstrated a DNS poisoning in under 10 seconds in 2008.
  • The fix for this was to extend the token size to 32bit using a hack involving the udp source ports. That does not really fix it...it just makes it harder (65363 times harder). So, in theory, an attacker can still poison dns servers. A good fix would be to implement DNSSEC.
  1. TCP attacks.

  • TCP reset attack

    • Forces to terminate the connection by sending a forged TCP reset packet
    • Used by the Great Firewall of China as a major way to carry out internet censorship
    • MITM can listen to a connection and send forged TCP reset packets
  • TCP sequence prediction attack

    • Attacker tries to predict the next sequence number used by the sending host
    • After the IP address of the host and the sequence number is known, it is basically a race to get the answer to the receiver
    • Can be combined with a DoS attack for higher efficiency
    • Can be used to perform TCP reset attacks
@evintila
Copy link

evintila commented Jun 3, 2017

  1. (https://www.inf.ed.ac.uk/teaching/courses/cs/1011/lecs/protocolsI.pdf)
    Lamport (p64): one-time password scheme
  • the server stores h^100 (P). (password hashed 100 times)
    Example: server stores h^(n+1) (P) (password hashed n+1 times)
    When the client sends h^(n)(P), the server computes h(h ^n (P)) - it hashes the received password again.
    If this is equal with h^(n+1) (P), the password is considered valid and the server now memorizes h^(n) (P)

Passcode generators: I do not what these are, but I guess that they are at least related to the "100 one-time passwords" part on the same slide 64.

So the difference between them is that the Lamport scheme requires the server to only memorize one password (h^n) instead of N passwords, but it also requires the client to compute a lot of hashes to reach h^(n-1). Also the server must always perform one hash per client (not a big problem).

@evintila
Copy link

evintila commented Jun 3, 2017

  1. (https://www.inf.ed.ac.uk/teaching/courses/cs/1011/lecs/protocolsII.pdf)
    p67
    a) The server sends to A: Kab, and {Kab, A}Kbs for A to send to B (only B should be able to decrypt it, since only he knows Kbs)
    b) Then A sends to B: {Kab, A}Kbs.

The rest doesn't matter. If E intercepts messages sent between A and B using their shared key Kab, eventually he will be able to break Kab: with huge amount of messages and a lot of time. Then E can copy and send {Kab, A}Kbs (see point b) and sent it to B tricking him to use Kab in his communication with E. Note that E doesn't even know "{Kab, A}" from "{Kab, A}Kbs".

Solution: add freshness: the server should send A {Kab, A, T}Kbs, where T is a timestamp. Then, if B receives its message from A, but the time since T is above a certain timeframe, he will reject it because it has expired.

@evintila
Copy link

evintila commented Jun 3, 2017

  1. (http://www.cs.bham.ac.uk/~mdr/teaching/modules06/netsec/lectures/DigitalCash.html)
    In offline digital cash, the coins are reusable and they have a transaction list. They can only be spent using a "Tamper-resistant device".
    The transaction list contains n identifiers looking like {p1, p2}, where p1 and p2 together (XORed) form an ID. In all of the identifiers, except the last one, one part (p1 or p2) is erased. The list is updated when the coin is transferred to another user (from a customer to a merchant). Thus anonymity is achieved.
    Protection against double spending is achieved using the transaction list:
    "If a user makes a copy of a coin before they spend it, they have the possibility to spend that coin again. However, when the coin is finally returned to the issuer, it will be possible to discover the culprit. This is achieved by combining a particular part of the identity from the original coin with its corresponding part from the copied coin. Note that the corresponding part will have been blanked out in the original coin."
    The possibility of catching a user is 1 - (1/2)^n, where n is the number of pairs used.

@RaulTsc
Copy link
Author

RaulTsc commented Jun 4, 2017

  1. Setuid vs seteuid.
  2. Bitcoin -- how does mining work. Does it do anything to provide value or people just believe it is worth something.

@RaulTsc
Copy link
Author

RaulTsc commented Jun 6, 2017

Chestii pe care nu sunt sigur:

  • Setuid vs seteuid (confused deputy)
  • Estimate passbreaking effort for a) 3 dicionary words, b) one l33t-speak word ?? nu inteleg ce e a si b. a 3 cuvinte random din dictionary? ce e b)?
  • RSA, DH, EG recap
  • C9 -- Protocols

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment