Interview_SOP/ CORS/ REST/ SOAP/ cache/ proxy/load balancing
π SOP, CORS, XXS, CSRF, SQL injection, XML injection
β What is origin?
- protocol β host β portβ What is SOP?
- Same Origin Policy- resource can be shared only between same server/same domain/same origin
β What are the benefits of SOP?
- prevent from malicious attacks such as XXS, CSRF, SQL injectionβ What is XXS? And how can we prevent?
- Cross Site Scripting- malicious scripts into web pages
- steal data, impersonate the user, or manipulate the webpage's content
- steal cookies, session tokens, credentials
π input validation
π output encoding
π CSP: content security policy
π μ€μ cookie HTTP ONLY
β Input validation μ΄λ»κ² ꡬννλμ§?
- νΌ λ°μ΄ν°- Script tag κ±Έλ¬μ£ΌκΈ°
- μΈνμ νΉμλ¬Έμ μμ νκΈ°, μΌλ° λ¬Έμλ‘ λ°κΎΈκΈ°
β What is CSRF? And how can we prevent?
- Cross Site Rquest Forgery- web-based attack - trick a user into performing an unwanted action on a website where they are already authenticated
- transfer funds, change passwords, or perform other actions without the userβs consent.
π CSRF token
π cookie `SameSite` only header
π CAPTCHA
β What is SQL injection? And how can we prevent?
- insert malicious SQL code- Use URL parameter, form fields, cookies, POST data, HTTP headers
- like delete user
π input validation
π sanitize user data
π WAF
β What XML injection? And how can we prevent?
- insert malicious code to trusted site- XML bomb
- XXE
π input validation
π sanitiza user data
π WAF
β What is CORS?
- Cross Origin Resource Sharing- for frontend, backend to communicate
β How can we prevent CORS error?
1. browser extension2. proxy server
3. backend settings: add `Access-Control-Allow-Origin` to `HTTP response header`
β What is proxy?
- Proxy between client and server as intermediary- Proxy server will allow resource shared between different origin
- solution to CORS error
π REST, SOAP
β What is SOAP? When is it used?
- Simple Object Access Protocol- Protocol to exchange structured information
- exchange XML messages
ππ» transaction, more secure
ππ» ACID(Automicity, Consistency, Isolation, Durability)
ππ» complex message
ππ» so strict! more rules.
β What is REST?
- Representational State Transfer- μμμ μ΄λ¦μΌλ‘ ꡬλΆ(URI), μμμ μνλ₯Ό μ£Όκ³ λ°κΈ°
- architectural structure to create APIs
- state: HTTP Status code
- HTTP URI, HTTP Method
β What is a Restful API? What are the conditions?
- API that follows the REST architecture- HTTP CRUD νΉμ§μ λ§μ΄ κ°μ§λ€.
- client-server
- statelessness
- cache
- layered system
- uniform interface
- URI
- self-descriptive message
- HATEOAS
- code-on-demand(optional)
β How is the maturity level of REST?
- URI- HTTP Methods
- HATEOAS
- L0: single URI, single verb
- L1: multiple URIs, single verb
- L2: multiple URIs, multiple verbs
- L3: HATEOAS
URI π URN π URL
β Difference between URI, URN, URL?
- URI β URL, URNβ Why do we need URN, when we have URL?
- location of the resource can change- URL can change
- URN will remain fixed
π Web cache
β What is web cache? What are the benefits of using cache?
- copied data to remember frequent requestππ» reduce network bottleneck
ππ» bandwidth β¬οΈ
β What is cache hit, miss?
- cache hit: find request in cache- cache miss: do not find request in cache, need to go to original server
β What is cache revalidation?
- check if cache data is identical to original server dataπ Proxy server
β What is proxy server?
- intermediary between server-client- connect application using same protocol
β Forward proxy server?
- ν΄λΌμ΄μΈνΈ μμ- exit point from client to server
- outbound traffic
- protect client information
β Reserse proxy server?
- μλ² μμ- entry point to server
- inbound traffic - protect server
β What are some functions of a proxy server?
- load balancing- security
- caching
- SSL termination
- filtering
- access control
- surrogate: reverse proxy
- contents router
- transcoder
- anoymizer
Proxy π Gateway
- proxy: connect application using same protocol- gateway: connect application using different protocol
Proxy π VPN
- proxy: handle network traffic- VPN: encrypt transmitted data
β Is WAF a reverse proxy?
- YES. intercept traffic before reaching serverπ Load Balancing
β What does a level 4 load balancer do?
- route traffic based on IPs and TCP, UDP ports- packet level load balancing
- unable to make routing decisions based on contet, media type, localization rules
- ASIC
β What does a level 7 load balancer do?
- routing decisions based on IP, TCP, UDP, ports, HTTP- makes content based routing decisions
- acts as a proxy: contain two TCP connections
(one with client, another with server)
π Request timeout
β Why do we use timeout?
- networks are unreliable- set a max wait time on request
- client: how long client will wait for response
- server: how long to maintain connection
β What is a connection timeout?
- how long the client will wait for a connection to establish- TCP μ°κ²° νλ¦½μ΄ μνλλλ° κ±Έλ¦¬λ μ΅λ μκ°
β What is a write timeout?
- how long connection will wait while the client tries to send a data, like POSTβ What is a read timeout?
- time it takes to recieve response back from the server- μμ²κ³Ό μλ΅μ΄ μνλλλ° κ±Έλ¦¬λ μ΅λ μκ°
This post is licensed under CC BY 4.0 by the author.