<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Clairehap on Medium]]></title>
        <description><![CDATA[Stories by Clairehap on Medium]]></description>
        <link>https://medium.com/@clairehap1?source=rss-75c39b3627b9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AQOTDd2bZngomntUrNuIAg.jpeg</url>
            <title>Stories by Clairehap on Medium</title>
            <link>https://medium.com/@clairehap1?source=rss-75c39b3627b9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:57:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@clairehap1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using PowerShell and AI to Build an Automated Excel Checklist]]></title>
            <link>https://medium.com/@clairehap1/using-powershell-and-ai-to-build-an-automated-excel-checklist-95d53f1d98c2?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/95d53f1d98c2</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[excel]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 01:48:54 GMT</pubDate>
            <atom:updated>2026-09-17T03:42:39.940Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve used PowerShell enough over the years to appreciate what it is really good at: making Windows do things that would otherwise involve an annoying amount of clicking.</p><blockquote>Need information about the machine? PowerShell. Need to work with Windows services? PowerShell. Need to create a scheduled task?</blockquote><blockquote>You guessed it- PowerShell.</blockquote><p>At the same time, I had been wanting to spend more time figuring out how AI could actually fit into my development process.</p><p>Not “type one prompt and have AI magically build an application”-</p><p>I wanted to see what happened when I treated an AI agent more like a development partner. Something I could use to research unfamiliar APIs, work through errors, challenge an approach, and iterate on a project with.</p><p>And conveniently, I had a problem sitting right in front of me.</p><p><em>(You can check out the public repo on GitHub </em><a href="https://github.com/ClaireHappel/AutoTask"><em>here</em></a><em>, or feel free to read the entire process of how I built this below).</em></p><h3>The World’s Most Overengineered Weekly Checklist:</h3><p>It feels like I’ve been saying for years, ‘Huh, I would really love an Excel checklist for personal use.’ Something to keep me grounded and on task.</p><p>And I actually started to make a list to help propel me forward in my job hunt. But one little thought that popped into the back of my head is- am I going to actually keep up with updating this <em>every</em> week? Do I really want to manually:</p><blockquote>Copy unfinished tasks into the next week.</blockquote><blockquote>Keep completed tasks somewhere.</blockquote><blockquote>Update the dates.</blockquote><blockquote>Save the old week data.</blockquote><blockquote>Repeat that forever.</blockquote><p>The more I thought about it, the more of a repetitive task it seemed- and all good programmers know that when something is repetitive, it brings one thought to mind.</p><blockquote><em>I could probably automate this.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7ZGbAjVTBVUtuF2VtBBww.png" /><figcaption>How hard could it be?</figcaption></figure><h3>Starting With What I Already Knew:</h3><p>My first instinct was PowerShell.</p><p>This was a Windows machine. Excel was installed locally. Windows already had Task Scheduler. PowerShell could talk directly to all of it.</p><p>But I didn’t particularly want the entire project to become one enormous PowerShell script. I wanted something another developer like me could examine and use- and I wanted something that I could add to later, if I felt the urge to build upon it.</p><p>Most of my current development work is in JavaScript and TypeScript, so I decided to use TypeScript for the actual project structure and let PowerShell handle the Windows-specific work.</p><p>That gave me a surprisingly useful combination:</p><pre>TypeScript<br>    ↓<br>PowerShell<br>    ↓<br>Windows / Excel</pre><p>The TypeScript application could handle configuration and orchestration, while PowerShell could do the things it was naturally good at.</p><p>And since I was developing inside WSL, things got a little more interesting.</p><h3>Linux vs. Windows Hiccups:</h3><p>The project runs from Ubuntu through WSL, but the Excel workbook lives on Windows. There are a lot of extra fun little quirks that come with that.</p><p>Things like a WSL path looking like this:</p><pre>/mnt/c/Users/username/Documents/AutoTask/Weekly_Checklist.xlsx</pre><p>needing to become something Excel understands, more like this:</p><pre>C:\Users\username\Documents\AutoTask\Weekly_Checklist.xlsx</pre><p>Fortunately, WSL gives us wslpath.</p><p>From TypeScript, I could convert the path before handing it over to PowerShell:</p><pre>const windowsChecklist = execFileSync(<br>  &#39;wslpath&#39;,<br>  [&#39;-w&#39;, checklist],<br>  { encoding: &#39;utf8&#39; },<br>).trim();</pre><p>Simple, sweet, and to the point.</p><p>And now my TypeScript application running in Linux could hand a proper Windows path to PowerShell.</p><h3>Keep It Simple:</h3><p>My first thought was to manipulate the .xlsx file directly with a JavaScript library. And technically, that worked. The data moved. The workbook opened.</p><p><em>Success!</em></p><p>Except the workbook formatting was getting <strong>destroyed</strong>. Dropdowns, styling, workbook behavior- all the things that made the spreadsheet actually pleasant to use suddenly became a much bigger problem.</p><p>This led to one of the more important architectural decisions in the project:</p><p><em>Why am I trying to recreate Excel’s behavior when I already have Excel? Sometimes the answer is to simplify instead of overcomplicate-</em></p><p>PowerShell can create an Excel COM object:</p><pre>$excel = New-Object -ComObject Excel.Application</pre><p>And from there, I can have the real desktop version of Excel open the workbook:</p><pre>$workbook = $excel.Workbooks.Open($checklist)</pre><p>And suddenly all of the existing formatting could stay <em>exactly</em> as it was.</p><h3>Building the Rollover:</h3><p>The main script became rollover.ts.</p><p>Its job is essentially to take the current weekly checklist and prepare it for the new week.</p><p>The workbook has three sheets:</p><ul><li>This Week contains the active tasks.</li><li>Task History contains completed tasks.</li><li>Settings controls things like whether unfinished tasks should carry forward and whether notes should be preserved.</li></ul><p>When rollover runs, it checks the actual system date and calculates the current Monday through Sunday. This ended up being more important than I initially expected.</p><p>At one point, I was simply moving the workbook forward one week every time the script ran. Which sounds perfectly reasonable- Until you’re testing the script fifteen times. Suddenly you’ve automated yourself directly into November.</p><p>The better solution was to make the system date the source of truth.</p><ul><li>Instead of: <em>Current workbook week + 7 days</em></li><li>The logic became: <em>What week are we actually in?</em></li></ul><p>That also fixed another problem: Weeks Carried.</p><p>An unfinished task shouldn’t gain another carried week just because I ran a script. So rather than incrementing, the program instead calculates the number of weeks between the task’s original carried date and the actual current week.</p><p>Now the operation is idempotent- running it repeatedly during the same week produces the same result.</p><p><em>Much</em> better.</p><h3>Storing Old Data:</h3><p>Before changing anything, the workbook gets copied into a Previous Weeks directory.</p><p>Something like:</p><pre>2026-09-07_to_2026-09-13.xlsx</pre><p>That archive is a complete copy of the workbook before rollover. Completed tasks and unfinished tasks are both still there exactly as they were during that week. Then the active workbook gets updated.</p><p>Completed tasks are placed into Task History, with the newest entries inserted at the top. Unfinished tasks stay in the active list if carry-forward is enabled. The new week’s dates are added. And Excel saves everything.</p><h3>Automating the Automation:</h3><p>Of course, having a rollover script still meant I had to remember to run the rollover script.</p><p>Which somewhat defeated the point.</p><p>Enter configure.ts.</p><p>The Settings sheet contains a rollover day (the default setting is Monday).</p><p>The configuration script opens the workbook, reads that setting, and uses PowerShell to create a Windows scheduled task.</p><p>The task is also configured with Windows’ StartWhenAvailable option.</p><p>Meaning if the rollover is supposed to happen Monday at 8:00 AM but the computer is turned off, Windows can run it the next time the machine becomes available. So now the spreadsheet effectively maintains itself (<em>victory!</em>).</p><h3>How AI Enhanced the Project:</h3><p>This project also became my excuse to spend more time working with an AI coding agent. And I think this was probably the most useful part of the experiment.</p><p>I wasn’t interested in asking:</p><blockquote><em>Build me an automated Excel checklist.</em></blockquote><p>and accepting whatever came back.</p><p>Instead, I used the agent throughout the development process. The workflow looked much more like:</p><pre>I define behavior<br>      ↓<br>AI suggests implementation<br>      ↓<br>I run it<br>      ↓<br>Something explodes<br>      ↓<br>We inspect the actual error<br>      ↓<br>Check documentation<br>      ↓<br>Fix it<br>      ↓<br>Run it again</pre><p>Which, come to think of it, is suspiciously similar to normal software development. The AI agent was especially helpful when I got outside the technologies I use every day.</p><p>I know PowerShell. I know TypeScript. But Excel COM automation has its own collection of wonderfully strange behaviors.</p><p>For example, copying values between cells turned out to behave differently depending on whether I directly assigned .Value2 or used Excel&#39;s own Copy() and PasteSpecial() methods.</p><p>Dates added another layer because Excel internally represents them as serial numbers.</p><p>PowerShell then has its own .NET types.</p><p>And all of this is crossing a boundary from Node running in WSL into PowerShell running on Windows and finally into Excel through COM.</p><p>There were several moments where the stack looked approximately like:</p><pre>TypeScript<br>→ Node<br>→ WSL<br>→ PowerShell<br>→ COM<br>→ Excel<br>→ Why is this a System.Double?</pre><p>The AI agent was useful here because I could give it the exact error, discuss what I thought was happening, and then use it to help navigate the relevant Microsoft documentation.</p><p>But the important part was still testing the answer! More than once, an idea that looked completely reasonable on paper turned out to behave differently when Excel actually got involved.</p><p>And that became one of the biggest lessons I took away from using AI in development:</p><p>AI is extremely useful for shortening the distance between “I don’t know this yet” and “I know what I need to test.” It helps to accelerate the learning process and allows for faster turnarounds once you have a solid idea architecturally of what you want to build.</p><p>That is a very different thing from blindly trusting generated code.</p><h3>The Human Still Has to Drive:</h3><p>One thing I liked about this project was that my existing technical knowledge still mattered constantly.</p><ul><li>Knowing PowerShell made it much easier to recognize where PowerShell belonged in the architecture.</li><li>Knowing TypeScript made it obvious that I didn’t want Windows automation logic controlling the entire application.</li><li>Understanding scheduled tasks helped me recognize that I didn’t need some continuously running Node process.</li><li>And knowing enough to recognize when a solution was getting absurdly complicated was probably one of the most important skills of all.</li></ul><p>There were points where the implementation started growing around problems instead of solving them. And that is where being able to direct an AI agent and veto its ideas, guiding it back to more appropriate solutions instead of letting it freely dictate the project came in handy.</p><h3>The End User Experience:</h3><p>The finished workflow is pretty simple from the user’s perspective.</p><p>You use an Excel checklist normally. Add your tasks. Set priorities. Give them due dates. Mark them complete.</p><p>And when the week changes:</p><ul><li>a copy of the old workbook is archived in the Previous Weeks folder</li><li>all completed tasks move into the Task History tab</li><li>and all unfinished tasks are properly brought into the new workbook for the week</li></ul><p>All of it happens locally. There’s no database. No server. No subscription. No application that has to stay running in the background.</p><p>Just:</p><ul><li>Excel</li><li>TypeScript</li><li>PowerShell</li><li>WSL</li><li>Windows Task Scheduler</li></ul><p>Which is perhaps a slightly ridiculous amount of technology for a weekly checklist- But that wasn’t really the point.</p><p>The point was taking something repetitive, applying technology I already understood, and using the parts I didn’t understand as an opportunity to learn.</p><p>PowerShell gave me a starting point. AI gave me a new way to explore the unfamiliar pieces. And somewhere along the way, my boring little Excel checklist became a surprisingly interesting automation project.</p><p>The end result, a working product I’ll be using, <a href="https://github.com/ClaireHappel/AutoTask">that I’ve made public for anyone who wants to check it out themselves</a>. Not bad for something that started with:</p><blockquote><em>I could probably automate this.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEDsE_SdZ-W2geBNk3zSoA.png" /><figcaption>It feels like I have my own little automated factory</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95d53f1d98c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Session Hijacking: How to Keep Identity Thieves Away From the Cookies They Crave]]></title>
            <link>https://medium.com/@clairehap1/session-hijacking-how-to-keep-identity-thieves-away-from-the-cookies-they-crave-9f172f2c4f83?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f172f2c4f83</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[identity-based-attacks]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Fri, 14 Aug 2026 13:16:58 GMT</pubDate>
            <atom:updated>2026-08-14T13:16:58.029Z</atom:updated>
            <content:encoded><![CDATA[<p>How many times have you personally been told to use a strong password? It’s a best security practice, it’s common sense when accessing a system full of sensitive information, and with two-factor authentication, password managers, and passkeys- most users consider themselves relatively secure.</p><p>But what if an attack’s target isn’t a password? What if instead, they bypass the need for a password completely by stealing <strong>cookies</strong>?</p><p>Welcome to the world of <strong>identity-based attacks </strong>and<strong> session hijacking</strong>: where attackers impersonate users by stealing authentication tokens and session identifiers, allowing them access to an application while bypassing authentication measures put in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*dzb4vx8yfNXu5WqR2neDlg.png" /><figcaption>Millions of cookies are stolen every year!</figcaption></figure><p><em>Minor note: The following article will be using JavaScript and backend related code structured for Express + Prisma- though concepts will be stack agnostic.</em></p><h3>What Is Session Hijacking?</h3><p><strong>Session hijacking</strong> is an attack where a valid session identifier is exploited, allowing for impersonation of already authenticated users.</p><p>The login flow for a secure application looks something like this:</p><pre>// a user provides their credentials<br>Username + Password<br>        ↓<br>// after credentials are provided- MFA double checks user identity<br>       MFA<br>        ↓<br>Successful Authentication<br>        ↓<br>// our server creates a session for the user<br>Application Creates Session<br>        ↓<br>// and gives the client a cookie<br>// the cookie tells the client &quot;keep this user logged in, they&#39;re good&quot;<br>Browser Receives Session Cookie</pre><p>Users love persisting sessions (especially if they needed to enter both credentials and deal with MFA) and developers love happy users- plus, this balances convenience and security. But this also means that if an attacker steals or guesses what an active session’s cookie is- they have access to anything the user can reach without a password re-entry, and can make authenticated requests while impersonating that victim.</p><h3>How Does Session Hijacking Happen?</h3><p>There are several methods attackers can use to potentially hijack a session: <strong>infostealer malware, adversary-in-the-middle phishing, XSS vulnerabilities, session fixation, weak session IDs, session sniffing, malicious browser extensions,</strong> and <strong>man-in-the-browser attacks </strong>are all ways someone with ill intentions might run off with a user’s cookies:</p><ul><li><strong>Infostealer Malware</strong>: infostealers are malware designed to collect data from an infected machine (passwords, browser cookies, authentication tokens, API credentials, those whacky digits linked to your crypto wallet). Even if sessions are configured correctly, the user’s infected device causes the session to be compromised.</li><li><strong>Adversary-in-the-Middle Phishing (AiTM): </strong>this phishing attack places the attacker between the victim and a service (thus- they are in the middle). In this attack, a user enters credentials for what appears to be a legitimate login (but surprise- it’s a trap!). The attacker proxies that communication to the real service and may then capture the authenticated session created.</li><li><strong>XSS and Insecure Token Storage</strong>: if an application stores authentication tokens somewhere JavaScript can access, such as localStorage, an XSS (cross-site scripting) vulnerability can let malicious scripts read and steal those tokens. Once stolen, the token may be reused to impersonate the victim’s authenticated session.</li><li><strong>Session Fixation</strong>: session fixation happens when an attacker knows a session ID <strong>before</strong> the victim logs in and tricks them into authenticating with that same session. If the server keeps the same identifier after authentication, the attacker doesn’t need to worry about ID changes.</li><li><strong>Weak Session IDs</strong>: most modern applications rely on server-side session middleware, such as express-session, to generate identifiers and associate them with session data. If a custom implementation uses predictable values, weak randomness, or sequential identifiers- it’s at risk of being guessed.</li><li><strong>Session Sniffing</strong>: if session data travels over an unencrypted connection, someone monitoring that traffic (sniffing) may be able to capture a valid session token and reuse it. Modern HTTPS has made traditional packet sniffing much harder, but improperly protected traffic can still expose active sessions.</li><li><strong>Malicious Browser Extensions:</strong> a malicious or compromised extension can abuse its permissions to inspect pages, inject scripts, or access sensitive browser data. Because extensions operate inside the user’s browser, they can steal or abuse authentication information without directly attacking a website.</li><li><strong>Man-in-the-Browser Attacks (MitB):</strong> these attacks compromise the browser environment itself (often via malware) allowing an attacker to monitor and manipulate activity inside the victim’s authenticated session.</li></ul><h3>What Is The Worst Case Scenario?</h3><p>A stolen session does not give someone complete control over an application- it simply gives them whatever the victim’s session had authorization to access.</p><p>For an average user, that may mean account takeover, exposure of personal information, fraudulent actions, or changes to account settings. It’s when a developer or administrator’s account is compromised that this attack hits its worst case scenarios. A privileged session could expose:</p><ul><li>source code repositories</li><li>cloud administration consoles</li><li>CI/CD pipelines</li><li>package registries and publishing accounts</li><li>production servers and infrastructure</li><li>databases containing customer or company data</li><li>internal admin tools</li><li>secrets, API keys, and deployment credentials</li></ul><p>Stealing sensitive data, changing security settings, making new credentials, moving into other systems are just the tip of the iceberg. If the victim had access to package publishing or deployment infrastructure- a single stolen session could escalate into a full-blown supply chain attack.</p><h3>Defense Basics:</h3><p>While there is no single fix for session hijacking, the ultimate goal of basic defense is to make sessions<strong> </strong>harder to steal, harder to reuse, and easier to invalidate.<strong> </strong>We can do this by:</p><h4><strong>Configuring Session Cookies Properly</strong>:</h4><p>Keep session identifiers in protected cookies rather than localStorage.</p><pre>app.use(session({<br>  // private values cannot be easily faked or changed<br>  secret: process.env.SESSION_SECRET,<br><br>  // don&#39;t save the session again if nothing changed<br>  resave: false,<br><br>  // don&#39;t create a session for someone until needed<br>  saveUninitialized: false,<br><br>  cookie: {<br>    // stops browser JS from reading session cookie (harder to steal)<br>    httpOnly: true,<br>    // only send the cookie over HTTPS connection <br>    // (helps reduce chance it&#39;s exposed by insecure connection)<br>    secure: process.env.NODE_ENV === &#39;production&#39;,<br><br>    // restricts when browser will send this cookie<br>    // (if request comes from a different website)<br>    sameSite: &#39;lax&#39;,<br><br>    // delete the cookie after 30 minutes<br>    // if stolen, it will expire (limits possible damage)<br>    maxAge: 1000 * 60 * 30,<br>  },<br>}));</pre><h4>Regenerating Sessions on Login:</h4><p>Changing the session ID immediately upon authentication prevents session fixation.</p><pre>app.post(&#39;/api/login&#39;, async (req, res, next) =&gt; {<br>  // check email and password actually belong to valid user<br>  const user = await validateCredentials(<br>    req.body.email,<br>    req.body.password,<br>  );<br><br>  // if credentials are invalid- an error is thrown<br>  if (!user) {<br>    return res.status(401).json({<br>      error: &#39;Invalid credentials&#39;,<br>    });<br>  }<br><br>  // old session ID replaced with new one<br>  // (prevents attacker from reusing session ID they knew prior to login)<br>  req.session.regenerate((err) =&gt; {<br>    if (err) return next(err);<br><br>    // new session now belongs to the authenticated user<br>    req.session.userId = user.id;<br><br>    res.json({<br>      message: &#39;Login successful&#39;,<br>    });<br>  });<br>});</pre><h4>Destroying Sessions on Logout:</h4><p>Explicitly destroy the session on the backend when a user logs out.</p><pre>app.post(&#39;/api/logout&#39;, (req, res, next) =&gt; {<br>  // delete user&#39;s session on the server<br>  // (old session ID no longer authenticates future requests)<br>  req.session.destroy((err) =&gt; {<br>    if (err) return next(err);<br><br>    // remove old cookie from user&#39;s browser<br>    res.clearCookie(&#39;sessionId&#39;);<br><br>    res.sendStatus(204);<br>  });<br>});</pre><h4>Reauthenticating:</h4><p>Forcing users to re-enter credentials before high-impact operations (ex: updating emails or passwords) limits potential damage from session hijacking.</p><pre>app.patch(&#39;/api/account/email&#39;, requireAuth, async (req, res, next) =&gt; {<br>  // get the current user using the ID stored in their session<br>  const user = await getUserById(req.session.userId);<br><br>  // check password entered against password saved for their account<br>  const isValid = await verifyPassword(<br>    req.body.password,<br>    user.passwordHash,<br>  );<br>  <br>  // stop the request if the password is wrong<br>  if (!isValid) {<br>    return res.status(401).json({<br>      error: &#39;Reauthentication required&#39;,<br>    });<br>  }<br><br>  // email only changes after the identity check<br>  await updateEmail(user.id, req.body.newEmail);<br><br>  res.sendStatus(204);<br>});</pre><h4>Make XSS Harder to Exploit:</h4><p>XSS allows injected scripts to abuse valid sessions. This can be done via relying on framework escaping and enforcing a strict Content Security Policy (CSP) via helmet.</p><pre>// helmet adds security-related HTTP headers to the app<br>import helmet from &#39;helmet&#39;;<br><br>app.use(helmet({<br>  contentSecurityPolicy: {<br>    directives: {<br>      // by default, only allow content to load from this website<br>      defaultSrc: [&quot;&#39;self&#39;&quot;],<br><br>      // only allow JavaScript files that come from this website<br>      // this makes it harder for injected scripts to run<br>      scriptSrc: [&quot;&#39;self&#39;&quot;],<br><br>      // do not allow embedded objects like Flash or other plugins<br>      objectSrc: [&quot;&#39;none&#39;&quot;],<br>    },<br>  },<br>}));</pre><h3>Defense Pro Edition:</h3><p>Attacks have evolved in complexity over time, and have become hard to contain even when implementing solid practices. When an infostealer rips a cookie from a user’s hard drive or an AiTM proxy intercepts it in transit- the passive defenses put in place completely fail.</p><p><em>But what if we shift from passive defense to actively killing hijacked sessions?</em></p><h4>Session Fingerprinting:</h4><p>When malware steals a cookie, the attacker usually uses it from a different network and a different machine. You might be able to detect this by “fingerprinting” the session at login — binding it to the user’s IP address and User-Agent. If the session suddenly appears with a different IP address or User-Agent, the server can treat it as suspicious and terminate it.</p><pre>// bind the fingerprint during login<br>app.post(&#39;/api/login&#39;, async (req, res, next) =&gt; {<br>  const user = await authenticateUser(req.body);<br><br>  req.session.userId = user.id;<br><br>  // save basic info about where the session started<br>  req.session.ip = req.ip;<br>  req.session.userAgent = req.get(&#39;User-Agent&#39;);<br><br>  res.json({ message: &#39;Success&#39; });<br>});<br><br>// check fingerprint on protected routes<br>function enforceFingerprint(req, res, next) {<br>  if (!req.session?.userId) {<br>    return res.status(401).send();<br>  }<br><br>  const currentIp = req.ip;<br>  const currentAgent = req.get(&#39;User-Agent&#39;);<br><br>  // if session context changes, it&#39;s suspicious-<br>  if (<br>    req.session.ip !== currentIp<br>    || req.session.userAgent !== currentAgent<br>  ) {<br>    // destroy suspicious session<br>    return req.session.destroy(() =&gt; {<br>      res.clearCookie(&#39;sessionId&#39;);<br><br>      res.status(403).json({<br>        error: &#39;Session context compromised.&#39;,<br>      });<br>    });<br>  }<br><br>  next();<br>}</pre><h4>Global Revocation via Session Versioning:</h4><p>If an attacker manages to hijack a session on a victim’s actual device, fingerprinting won’t catch it.</p><p>Session Versioning attaches a matching version number to both a user’s cookie and their account in the database. The moment the user does something like change their password, the database bumps that number up, instantly killing any active session using the old one (aka the global revocation that kills all sessions across all devices).</p><pre>// save current version when the session is created<br>req.session.userId = user.id;<br>req.session.version = user.sessionVersion;<br><br>// check session version on sensitive requests<br>async function enforceSessionVersion(req, res, next) {<br>  if (!req.session?.userId) {<br>    return res.status(401).send();<br>  }<br><br>  // get current valid session version from the database<br>  const user = await prisma.user.findUnique({<br>    where: { id: req.session.userId },<br>    select: { sessionVersion: true },<br>  });<br><br>  // if versions no longer match, session revoked<br>  if (req.session.version !== user.sessionVersion) {<br>    return req.session.destroy(() =&gt; {<br>      res.status(401).json({<br>        error: &#39;Session revoked.&#39;,<br>      });<br>    });<br>  }<br><br>  next();<br>}<br><br>// invalidating the session across all devices<br>app.post(&#39;/api/security/logout-everywhere&#39;, async (req, res) =&gt; {<br>  await prisma.user.update({<br>    where: { id: req.session.userId },<br>    data: {<br>      sessionVersion: {<br>        increment: 1,<br>      },<br>    },<br>  });<br><br>  // destroy the session making this request too<br>  req.session.destroy(() =&gt; {<br>    res.json({<br>      message: &#39;All sessions globally revoked.&#39;,<br>    });<br>  });<br>});</pre><h4>Absolute and Idle Timeouts:</h4><p>Standard cookies reset their expiration timer every time a request is made. If an attacker writes a script to fetch data every 5 minutes with a stolen cookie, the session will live forever. You must enforce hard cut-offs on the server.</p><pre>// set these whensession is created<br>req.session.createdAt = Date.now();<br>req.session.lastAccessed = Date.now();<br>// 30 minutes<br>const IDLE_TIMEOUT = 1000 * 60 * 30; <br>// 12 whole hours<br>const ABSOLUTE_TIMEOUT = 1000 * 60 * 60 * 12; <br><br>function enforceStrictTimeouts(req, res, next) {<br>  if (!req.session?.userId) {<br>    return next();<br>  }<br><br>  const now = Date.now();<br><br>  // how long since session was last used<br>  const idleTime = now - req.session.lastAccessed;<br><br>  // how long session has existed<br>  const totalAge = now - req.session.createdAt;<br><br>  // end the session if either timeout has been reached<br>  if (<br>    idleTime &gt; IDLE_TIMEOUT<br>    || totalAge &gt; ABSOLUTE_TIMEOUT<br>  ) {<br>    return req.session.destroy(() =&gt; {<br>      res.status(401).json({<br>        error: &#39;Session expired.&#39;,<br>      });<br>    });<br>  }<br><br>  // the user is still active, so update the idle timer<br>  req.session.lastAccessed = now;<br><br>  next();<br>}</pre><h4>Fetch Metadata Enforcement:</h4><p>Adversary-in-the-Middle attacks trick users into logging into a proxy domain, which relays the traffic to your real server. You can stop these proxies from requesting data by rejecting any request that doesn&#39;t originate from your exact domain, using modern Sec-Fetch headers.</p><pre>function blockCrossSiteRequests(req, res, next) {<br>  // tells whether browser request started on another website<br>  const fetchSite = req.get(&#39;Sec-Fetch-Site&#39;);<br><br>  // block requests the browser identifies as cross-site<br>  if (fetchSite === &#39;cross-site&#39;) {<br>    return res.status(403).json({<br>      error: &#39;Cross-site request blocked.&#39;,<br>    });<br>  }<br><br>  next();<br>}<br><br>// apply check to API routes<br>app.use(&#39;/api&#39;, blockCrossSiteRequests);</pre><h3>Am I Safe If I Don’t Use Cookies?</h3><p><strong>Identity-based attacks</strong> don’t stop at sessions and cookies. Attackers can target other reusable authentication credentials through <strong>token theft and replay</strong>, including <a href="https://www.geeksforgeeks.org/web-tech/json-web-token-jwt/"><strong>JSON Web Tokens (JWTs)</strong></a><strong>.</strong></p><p>The fact that a token is cryptographically signed does <strong>not</strong> prevent someone from stealing it. While the signature protects the token from modification- it does not protect it from being copied.</p><h3>Session Security in the Future:</h3><p>Session security has been moving away from a more simple form of authentication and transitioning into something a bit more difficult to take advantage of. Newer approaches tie sessions or tokens to a specific device, cryptographic key, or certificate:</p><ul><li><strong>Device Bound Session Credentials (DBSC):</strong> Google’s approach for binding browser sessions to a cryptographic key stored on the user’s device. This makes it harder to reuse stolen cookies elsewhere.</li><li><strong>Microsoft Entra Token Protection:</strong> Binds supported authentication tokens to the device they were issued to, helping prevent stolen tokens from being replayed on another device.</li><li><strong>Demonstrating Proof of Possession:</strong> An OAuth standard where the client must prove it owns a private key when using an access token.</li><li><strong>Certificate-Bound Tokens (mTLS):</strong> Ties an OAuth token to a client certificate. This means the token alone is not enough without its matching certificate.</li></ul><p>This won’t eliminate session hijacking entirely, but stolen session credentials will be significantly less useful outside the device where they were created. But the process of adoption is slow, and in some ways- the best way to fight against these attacks is to minimize the potential damage when they occur.</p><h3>Is This Attack Still Relevant?</h3><p>Even with the industry shifting in response- this attack still remains relevant, impacting major organizations frequently on a widespread scale. There is a lot of money to be potentially made through session hijacking- and even if best practices exist, there is no guarantee that they have been implemented across all corners of the web. A few notable attacks from recent years include:</p><ul><li><strong>Okta Support System Breach — 2023:</strong> Attackers stole HAR files uploaded to Okta support that contained <strong>active session tokens</strong>. Those tokens could be replayed to impersonate authenticated administrators at customers including Cloudflare and BeyondTrust without going through the normal login process again.</li><li><strong>CircleCI — 2023:</strong> Malware compromised an engineer’s laptop and stole a valid <strong>2FA-backed SSO session</strong>. The attacker reused that authenticated session to access CircleCI systems and steal customer secrets and credentials. This is one of the clearest real-world examples of session theft bypassing MFA entirely.</li><li><strong>Tycoon2FA — 2025–2026:</strong> One of the biggest recent AiTM phishing operations. Tycoon2FA sat between victims and legitimate login pages, captured authenticated <strong>session cookies</strong>, and let attackers bypass MFA by replaying those sessions. Europol linked it to nearly 100,000 attacks on organizations globally.</li><li><strong>Lumma Stealer — 2025:</strong> One of the most widespread infostealers of 2025. Lumma stole <strong>browser session cookies</strong>, saved passwords, and other browser data from Chromium- and Mozilla-based browsers. Microsoft reported roughly <strong>394,000 Windows infections in just a two-month period</strong> before a major international disruption operation in May 2025.</li></ul><h3>In Conclusion</h3><p>The need for security doesn’t stop when a login succeeds and because of that- authentication shouldn’t either.</p><p>Where is a session stored? Can JavaScript access it? How long does it live? Can it be revoked? And what can a user access if they manage to bypass the password of an ordinary user or one with admin access?</p><p>While we spent years making passwords harder to steal and harder to use, attackers evolved by targeting something potentially more valuable: the session of someone already logged in.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f172f2c4f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supply Chain Attacks: Trust Your Instincts, Not Vulnerable Packages]]></title>
            <link>https://medium.com/@clairehap1/supply-chain-attacks-trust-your-instincts-not-vulnerable-packages-f7430e581e37?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7430e581e37</guid>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 14:02:01 GMT</pubDate>
            <atom:updated>2026-08-04T17:44:19.486Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent years, cybersecurity attacks have risen sharply in scope and complexity. Awareness of how attacks occur and how to fight them are key in helping to mitigate the number of breaches that leave sensitive user and company related information up for grabs.</p><p>In an effort to sharpen cybersecurity skills, I’ve been seeking to learn how certain vulnerabilities and exploits occur, identifying where attacks happen and how to prevent them. This week, my focus isn’t on exploits within code (such as the topic I previously tackled, prototype pollution) but instead on attacks aimed at the tools developers use.</p><p>A variety of attack that does exactly this is the supply chain attack, which occurs when an attacker targets something your application already trusts instead of hitting it directly.</p><p>By hijacking a popular npm package or stealing the credentials of an account that manages such a package- legitimate tools meant to aid developers suddenly become vectors to drop malicious payloads to untold numbers of unsuspecting users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*F1ghAT0n9ZKFmw-S" /><figcaption><a href="https://appomni.com/blog/saas-supply-chain-attacks-mitre-attck-mapping/">One weak link is all it takes!</a></figcaption></figure><h3><strong>How Does A Supply Chain Attack Occur?</strong></h3><h4><strong>Compromised maintainer accounts + good packages turned bad</strong> :</h4><p>Accounts with high level access to tools with high traffic are frequently subjected to attempted attacks. Using phishing, malware, weak account security or tokens leaked- attacks steal credentials to authors of major npm packages or Github repos, and then publish malicious versions of legitimate packages. These packages may contain credential-stealing or backdoor code.</p><h4><strong>Typosquatting and dependency confusion:</strong></h4><p>Instead of directly attacking a trusted tool, attackers may publish packages with misleading names or names matching private internal packages. You may have seen similar tactics aimed at hijacking site names very close to that of popular websites (which is why large organizations often prepare measures to account for user error when typing urls) or malware hidden within downloads that masquerade as popular software (which is why it’s widely advised to download updates and software from official sites directly).</p><h4><strong>Compromised transitive dependencies:</strong></h4><p>Packages within npm are often have dependencies that are automatically installed when users install their desired packages. If they download 30 packages but indirectly install hundreds- each of those packages represent an opportunity to compromise a major package from one of these smaller dependencies within the tree.</p><h4><strong>npm lifecycle scripts:</strong></h4><p>Instead of modifying the package itself, an attack may add additional scripts tacked on to packages that are executed during installation-postinstall scripts have been a favorite target recently:</p><pre>{ &quot;scripts&quot;: { &quot;postinstall&quot;: &quot;node setup.js&quot; } }</pre><p>A malicious postinstall script can run before the package is ever imported. It may read environment variables, SSH keys, npm tokens, cloud credentials, or source code.</p><h4><strong>Compromised GitHub Actions</strong> :</h4><p>A compromised Github Action is another potential target. Tags such as v3 are mutable. If the Action or its repository is compromised, the tag can be redirected to malicious code without any change appearing in your repository.</p><h4><strong>Compromised CDN scripts:</strong></h4><p>Loading JavaScript directly from another company gives that company’s infrastructure permission to execute code in a user’s browser. If that service is compromised, the script can change without you redeploying your website.</p><h3><strong>What Is Required For The Attack To Happen?</strong></h3><p>From the previous examples- we can see a pattern of the essential requirements to successfully pull off supply chain attack. The four required elements are:</p><ul><li><strong>Trust</strong>: Your project trusts a tool- either a package, maintainer, Action, CDN, or build service.</li><li><strong>Access</strong>: This tool is compromised when an attacker gains access via stealing a publishing token, compromising a repository, or taking over a maintainer account.</li><li><strong>Distribution: </strong>Malicious code is then delivered to users through npm, an automated update, a GitHub workflow, a CDN, etc.</li><li><strong>Execution</strong>: The compromised code runs on a developer machine, CI runner, production server, or user’s browser.</li></ul><h4><strong>What Are the Worst-Case Scenarios?</strong></h4><p>The impact depends heavily on permissions. Malicious code running inside a release pipeline with GitHub, npm, and cloud credentials can cause far more damage than code running in an isolated test environment.</p><ul><li><strong>Credential theft: </strong>attackers may steal: GitHub tokens, npm publishing tokens, credentials, SSH keys, database passwords, and much more.</li><li><strong>Production compromise: </strong>stolen deployment credentials can allow attackers to modify production applications, access databases, replace container images, or create persistent cloud accounts.</li><li><strong>Compromised users: </strong>malicious frontend code can capture form data, authentication tokens, payment details, or application data directly from users’ browsers.</li><li><strong>Further supply chain attacks: </strong>an infected developer machine may expose credentials for other npm packages. The attacker can then compromise those packages and spread the attack further.</li><li><strong>Destruction or ransomware: </strong>attackers may delete repositories, destroy resources, encrypt systems, or publish destructive package updates.</li></ul><h4><strong>How to Prevent Supply Chain Attacks</strong></h4><p>No single tool or strategy will prevent every potential attack. The goal is to reduce trust, permissions, and automatic execution.</p><ul><li><strong>Lock dependency versions: </strong>commit your lockfile and use “clean install” instead of npm install to avoid unintentional updates or lockfile changes:</li></ul><pre>// perform a clean install<br>npm ci</pre><ul><li><strong>Review dependency changes: </strong>check<strong> n</strong>ewly added dependencies, new package maintainers, ownership changes, lifecycle scripts, unexpected lockfile changes, large generated or minified files, packages with little maintenance history</li><li><strong>Limit install scripts: </strong>when possible-<strong> </strong>install dependencies without running lifecycle scripts (though keep in mind a legitimate package could very well require an install script- test things before enforcing this):</li></ul><pre>// ignores scripts during install<br>npm ci - ignore-scripts</pre><ul><li><strong>Pin GitHub Actions to commit hashes: </strong>the v3 tag can move. A commit SHA is <em>immutable</em>.</li></ul><pre>// avoid mutable references:<br>vendor/example-action@v3 <br>// prefer a verified full commit SHA:<br>vendor/example-action@8f4b7c…full-commit-sha</pre><ul><li><strong>Restrict workflow permissions: </strong>give CI jobs only the permissions they require. Testing workflows should not normally have package-publishing or production-deployment credentials.</li><li><strong>Separate testing from publishing: </strong>do not run untrusted pull-request code inside the same environment used to publish packages or deploy production applications.</li><li><strong>Use trusted publishing: </strong>where supported, use OpenID Connect instead of storing permanent npm publishing tokens in GitHub Actions. Trusted publishing provides short-lived credentials tied to a specific workflow. This reduces the value of stolen CI secrets, though it cannot protect workflows that are already compromised.</li><li><strong>Protect maintainer accounts: </strong>with passkeys or hardware security keys, two-factor authentication, short-lived access tokens, branch protection, required pull-request reviews, and protected release environments.</li><li><strong>Control third-party browser scripts: </strong>when possible, self host scripts that are important. Otherwise, use Content Security Policy (CSP) and Subresource Integrity (SRI):</li></ul><pre>&lt;script <br>  src=&quot;https://cdn.example/library.js&quot; <br>  integrity=&quot;sha384-EXPECTED_HASH&quot; <br>  crossorigin=&quot;anonymous&quot;&gt; <br>&lt;/script&gt;</pre><ul><li><strong>When compromised, act immediately:</strong> when hit by a malicious package that executes, assume it can read everything available to that process. Quarantine and take immediate action: 1) isolate affected machines, 2) revoke sessions and access tokens, 3) rotate npm, GitHub, cloud, SSH, and deployment credentials 4) review repositories and workflows for unauthorized changes and 5) rebuild from a clean environment.</li></ul><h4>Bonus: More Ways To Defend:</h4><p><strong>Environment Variable Sanitization (Node.js):</strong></p><ul><li>load environment variables into frozen application state at startup, then immediately wipe <em>process.env</em> so untrusted sub-dependencies can&#39;t read them.</li></ul><pre>// run this as the very first import in your application entry point<br>import dotenv from &#39;dotenv&#39;;<br>dotenv.config();<br><br>// copy req credentials into a frozen, read-only object<br>export const config = Object.freeze({<br>  dbUri: process.env.DATABASE_URL,<br>  apiSecret: process.env.API_SECRET,<br>  stripeKey: process.env.STRIPE_SECRET_KEY,<br>});<br><br>// clear sensitive keys from process.env so malicious packages can&#39;t steal them<br>const SENSITIVE_KEYS = [&#39;DATABASE_URL&#39;, &#39;API_SECRET&#39;, &#39;STRIPE_SECRET_KEY&#39;, &#39;NPM_TOKEN&#39;, &#39;AWS_SECRET_ACCESS_KEY&#39;];<br><br>SENSITIVE_KEYS.forEach((key) =&gt; {<br>  delete process.env[key];<br>});</pre><p><strong>Lock Down Global Prototypes (Node.js &amp; Browser):</strong></p><ul><li>freeze built-in prototypes before importing or executing third-party modules.</li></ul><pre>// freeze-prototypes.js - Import before third-party libraries<br><br>// prevent dependencies from modifying built-in prototype behavior<br>Object.freeze(Object.prototype);<br>Object.freeze(Array.prototype);<br>Object.freeze(Function.prototype);<br><br>// any library trying to mutate Object.prototype will fail<br>try {<br>  Object.prototype.polluted = true;<br>} catch (e) {<br>  console.log(&#39;Prototype pollution blocked successfully!&#39;);<br>}</pre><p><strong>Dynamic Script Integrity Checker (Browser JS):</strong></p><ul><li>Enforce Subresource Integrity (SRI) hashes programmatically before appending scripts to the DOM</li></ul><pre>/**<br> * Safely loads a third-party script with mandatory SRI hash verification.<br> * @param {string} url - CDN URL of the script<br> * @param {string} hash - SHA-384 or SHA-512 SRI hash<br> */<br>function loadThirdPartyScript(url, hash) {<br>  return new Promise((resolve, reject) =&gt; {<br>    const script = document.createElement(&#39;script&#39;);<br>    script.src = url;<br>    // abort execution if hash doesn&#39;t match<br>    script.integrity = hash; <br>    script.crossOrigin = &#39;anonymous&#39;;<br>    <br>    script.onload = () =&gt; resolve(`Loaded successfully: ${url}`);<br>    script.onerror = () =&gt; reject(new Error(`SRI Validation Failed or Network Error for ${url}`));<br><br>    document.head.appendChild(script);<br>  });<br>}<br><br>// example<br>loadThirdPartyScript(<br>  &#39;https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js&#39;,<br>  &#39;sha512-wowthisisNOTTRUSTWORTHY+&#39;<br>).catch(err =&gt; console.error(&#39;Blocked untrusted script:&#39;, err));</pre><p><strong>Custom Package Lifecycle Script Auditor:</strong> make a Node.js script you can run in your npm test pipeline to automatically fail the build if any installed package contains execution scripts.</p><pre>// our imports<br>import fs from &#39;fs&#39;;<br>import path from &#39;path&#39;;<br><br>function checkNodeModules(dir) {<br>  const nodeModulesPath = path.join(dir, &#39;node_modules&#39;);<br>  if (!fs.existsSync(nodeModulesPath)) return;<br><br>  const packages = fs.readdirSync(nodeModulesPath);<br>  let dangerousPackages = [];<br><br>  packages.forEach((pkg) =&gt; {<br>    const pkgJsonPath = path.join(nodeModulesPath, pkg, &#39;package.json&#39;);<br>    if (fs.existsSync(pkgJsonPath)) {<br>      const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, &#39;utf8&#39;));<br>      const scripts = pkgJson.scripts || {};<br>      <br>      // check for dangerous install hook scripts<br>      if (scripts.postinstall || scripts.preinstall || scripts.install) {<br>        dangerousPackages.push({ name: pkg, scripts });<br>      }<br>    }<br>  });<br><br>  if (dangerousPackages.length &gt; 0) {<br>    console.error(&#39;Warning: Found installed packages with lifecycle scripts:&#39;);<br>    console.table(dangerousPackages);<br>    process.exit(1); // Fail CI pipeline<br>  } else {<br>    console.log(&#39;No unauthorized install scripts detected.&#39;);<br>  }<br>}<br><br>checkNodeModules(process.cwd());</pre><h4><strong>Do Supply Chain Attacks Matter Today?</strong></h4><p>These practices are incredibly relevant to the present- supply chain attacks are not things of the past- they are the attacks of the present and will only continue to grow in importance in the future as- they are widely anticipated to be one of the define threats in cybersecurity within the next decade. They provide massive ROI for attackers and modern codebases are highly dependent on third-party code. To keep up with the dangers, a shift is occurring where defensively- experts are trying to be less reactive and more proactive with warding off attacks.</p><p>To give a brief overview- here are some recent supply chain attacks that have caused widespread issues:</p><h4><strong>Shai-Hulud — September &amp; November 2025:</strong></h4><blockquote>Named after the giant worms from<strong> </strong>Dune by Frank Herbert<strong>, Shai-Hulud</strong> was a self-replicating npm worm that spread through compromised maintainer accounts and malicious package installation scripts. It searched infected systems for npm tokens, GitHub personal access tokens, and cloud credentials. When it discovered npm publishing rights, it automatically infected other packages maintained by the victim account. CISA reported over 500 compromised packages in the initial wave, with subsequent variants (<strong>Shai-Hulud 2.0</strong>) introducing wiper behavior if command-and-control access was lost.</blockquote><p>This Demonstrated <strong>t</strong>hat npm attacks can operate as self-propagating worms, leveraging a developer’s credentials to systematically compromise downstream packages and maintainers.</p><h4><strong>Mini Shai-Hulud &amp; TanStack — May 2026</strong></h4><blockquote>A subsequent campaign known as <strong>Mini Shai-Hulud</strong> compromised over 170 npm packages and multiple PyPI packages across hundreds of malicious releases, including popular TanStack libraries.</blockquote><blockquote>The attack utilized obfuscated install-time scripts to exfiltrate credentials. OpenAI reported two employee devices were impacted after routine package updates, resulting in limited credential exfiltration from internal repositories accessible to those systems.</blockquote><p>This Demonstrated that even organizations with advanced security postures remain vulnerable when trusted dependencies execute malicious code during routine package installation.</p><h4><strong>Nx S1ngularity — August 2025</strong></h4><blockquote>Attackers exploited a vulnerability in the Nx project’s GitHub Actions workflow to extract an npm publishing token. They subsequently published malicious versions of multiple official Nx packages that executed post-install malware to steal credentials and upload them to public GitHub repositories.</blockquote><p>This demonstrated that a security flaw in CI/CD automation can translate directly into a widespread downstream package registry compromise.</p><h4><strong>tj-actions/changed-files — March 2025</strong></h4><blockquote>Attackers compromised the maintainer pipeline of tj-actions/changed-files—a popular GitHub Action used across 23,000+ repositories—and redirected existing version tags (@v4, etc.) to point to a malicious commit designed to leak repository secrets via workflow logs.</blockquote><p>This demonstrated why referencing mutable version tags in workflows is dangerous; workflow logic can change unexpectedly without any modifications to your project’s source code.</p><h4><strong>Polyfill.io — June 2024</strong></h4><blockquote>Following an ownership transition of the popular Polyfill.io domain, the CDN service began injecting malicious JavaScript redirects and tracking payloads into thousands of production websites loading scripts directly from the service.</blockquote><p>This demonstrated that unverified dynamic JavaScript from external CDNs delegates execution authority to an external provider on every single HTTP request.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7430e581e37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototype Pollution: Reduce Attacks and Recycle Best Practices]]></title>
            <link>https://medium.com/@clairehap1/prototype-pollution-reduce-attacks-and-recycle-best-practices-e429ef77c3df?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e429ef77c3df</guid>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Wed, 15 Jul 2026 13:55:09 GMT</pubDate>
            <atom:updated>2026-07-15T13:55:09.166Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript, as the most widely used language on the web- is constantly caught up in a battle of protecting against vulnerabilities and having new pain points exposed and exploited. Whether working with older code with known vulnerabilities lurking within it or new code that lacks the robustness and well-formed security of a well tested application- exploits across the web have become increasingly prevalent. Those prone to using their code for more malicious means abound, and understanding how to create code and implement best security practices is more critical than ever. New ways to implement old exploits have become particularly prevalent during the rise of AI.</p><p>This knowledge is what inspired me to dive into learning more about the types of attacks and how to combat them.</p><p>An attack that particularly drew my attention was Prototype Pollution: while often unexploitable on its own- through chaining, Prototype Pollution can become the spearhead of a series of chained vulnerabilities that can even lead to remote code execution.</p><h3>What is Prototype Pollution?</h3><p>If you’ve ever dived into exploring how an object is able to access it’s methods- you have likely seen the Object prototype, which dictates the behavior of all objects.</p><p>The Prototype Pollution vulnerability occurs when a __proto__ property of a JavaScript object is used in order to inject unauthorized properties on the global Object.prototype.</p><p>Inheritance is a major feature in JavaScript and since most objects inherit from the root prototype, the pollution of this single Object. prototype changes the behavior of all objects across an entire application during an object pollution exploit. Attackers use this to inject properties that bypass authorization, crash systems, or alter the logic of an application completely.</p><p>To ask yourself how this happens, consider how inheritance works- if objects are constantly referring back to their parents in a chain of inheritance, and the top of the chain is poisoned- each child likewise becomes poisoned.</p><h3>How does it commonly occur?</h3><p>Prototype pollution vulnerabilities occur when a function is used to recursively merge an object into an existing object without implementing key sanitization. This allows for potential injection of other properties such as __proto__, alongside other nested properties (which we will touch on more in a minute).</p><p>Because __proto__ is particularly important in a JavaScript context, this merge operation can assign properties not just to the object itself, but it’s prototype.</p><p>Because of this, the attacker gains access to a way to directly pollute the prototype with unexpected values and manipulate the application to use these values in malicious ways.</p><h3>What is required for the exploit?</h3><p>This attack generally occurs with the the built-in global Object.prototype, but it’s possible for another prototype to be the target. To make this exploit succeed, attackers need:</p><ul><li>A prototype pollution source. The most common sources are:<br> — The URL<br> — JSON-based input<br> — Web messages</li><li>A sink — aka, any element that enables code execution. Through the sink, you can potentially reach any number of other sinks. Some developers unfamiliar with this attack may not fully set up sanitization, assuming that no user could access certain properties. If this happens, the attacker will have access to anything not behind filters or sanitized.</li><li>An exploitable gadget — Gadgets are the tools that turn this vulnerability into a full blown exploit. To become truly dangerous, this property the attacker is seeking to add on to an object must not be sanitized or filtered, and instead be allowed to be inherited by an object despite the malicious functionality it allows.</li></ul><h3>What’s the worst that could happen?</h3><p>If any attacker pieces together what they need to succeed in this attack (source, sink, and gadget) the following fallout can be catastrophic. In worst case scenarios, the following can happen:</p><p>• <strong>Privilege Escalation</strong>: Since the attacker has full control, they inject properties like isAdmin, role: ‘superadmin’, or isAuthenticated: true. If checks exist within an application regarding these, the attacker suddenly gain full privileges to a system and from here- see sensitive data related to users and potentially wreak further havoc.<br>• <strong>Denial of Service (DoS)</strong>: If the attacker overwrites a critical, built-in method within JavaScript, they can cause an instant crash within the engine itself. The application goes down, users are locked out, potential data is lost.</p><h3>How to fix it:</h3><p>To secure an application fully against this attack, we need to catch these errors and fully lock down our objects via ether breaking the lookup chain or preventing the possibility of mutation of our prototypes completely.</p><h4>Fix 1: Prototype-less Objects</h4><p>Pro: What better way to stop a prototype chain based attack then to ensude that said chain doesn’t exist? If objects are created via Object.create(null), they will not inherit from Object.prototype. This leads to __proto__ evaluating to undefined.</p><p>Example:</p><pre>// we create an object safely<br>const safeDataStorage = Object.create(null); <br><br>// even if a hypothetical attacker attempts to traverse __proto__, there is nothing to access<br>console.log(safeDataStorage.__proto__); // =&gt; undefined</pre><p>Con: You lose access to built-in object methods like hasOwnProperty() on that object instance, though to access methods you can use the following syntax: Object.prototype.hasOwnProperty.call(safeDataStorage, key) in order to borrow them.</p><h4>Fix 2: Object Freezing</h4><p>Pro: Freezing the global prototype at the very start of your application (such as index.js or server.js) will prevent any modifications being added. It’s the equivalent of a complete lockdown.</p><p>Example:</p><pre>// execute this prior to loading servers or route middleware<br>Object.freeze(Object.prototype); <br><br>const attackTarget = {}; <br><br>// this mutation will now fail silently or throw an error<br>attackTarget.__proto__.isAdmin = true; <br>console.log(({}).isAdmin); // =&gt; undefined </pre><p>Con: If you’re using 3rd party legacy libraries that work off of extended native prototypes- you’ll run into major compatibility issues and your code using methods related to said libraries will not work.</p><h4>Fix 3: Utilizing ES6 Maps</h4><p>Replace plain objects with ES6 Map objects. Map elements are stored as key-value pairs and will not map to the prototype chain when keys like __proto__ are set- thus protecting your existing objects.</p><p>Example:</p><pre>// here is our beautiful, secure map<br>const secureLookup = new Map(); <br><br>// now if an attacker attempts to set a malicious key-<br>secureLookup.set(&#39;__proto__&#39;, { isAdmin: true }); <br><br>// the structure remains secure because it treats &quot;__proto__&quot;  as a string key<br>console.log(({}).isAdmin); // =&gt; undefined</pre><p>Con: Maps do not have native JSON support and a good chunk of memory overhead. They’ll consume much more memory than an object of similar size.</p><h4>Fix 4: Proxies</h4><p>Create a security guard for your objects via proxies. By wrapping objects in Proxies, we can actively prevent any modifications, completely customizing what should and should not be allowed to modify our keys and properties. The set and defineProperty traps can halt any attempts to write to __proto__ and constructor, shutting attacks down before they ever happen.</p><pre><br>// we create a lovely proxy to wrap around our beautiful target<br>function createSafeObject(target = {}) {<br>    return new Proxy(target, {<br>        set(target, key, value, receiver) {<br>            // intercept and block attempts to mutate prototype-related keys<br>            if (key === &#39;__proto__&#39; || key === &#39;constructor&#39;) {<br>                throw new TypeError(`Access to property &quot;${key}&quot; is strictly forbidden.`);<br>            }<br>            // and also use Reflect to execute safe, default behavior<br>            return Reflect.set(target, key, value, receiver);<br>        },<br>        defineProperty(target, key, descriptor) {<br>            // and block pesky bypasses of Object.defineProperty()<br>            if (key === &#39;__proto__&#39; || key === &#39;constructor&#39;) {<br>                throw new TypeError(`Defining property &quot;${key}&quot; is strictly forbidden.`);<br>            }<br>            return Reflect.defineProperty(target, key, descriptor);<br>        }<br>    });<br>}<br><br>const userProfile = createSafeObject({});<br><br>// now when an attacker tries to modify something<br>try {<br>    userProfile.__proto__.isAdmin = true;<br>} catch (error) {<br>    console.error(&quot;Attack Blocked:&quot;, error.message); <br>    // =&gt; Attack Blocked: Access to property &quot;__proto__&quot; is strictly forbidden.<br>}</pre><p>Example:</p><p>Con: Wrapping every object in a Proxy can get memory intensive quickly because every single property access must run through the custom trap functions (and the more functions and objects they are, the worse this scales). Developers using Proxies need to be careful to interact with the proxy itself, as working with the raw target can lead to it being leaked and provide a way to bypass the proxy itself.</p><h3>In Conclusion:</h3><p>Prototype Pollution is evidence that to know how to protect against attacks, developers need a deep understanding of the characteristics of the language they work with. JavaScript is particularly vulnerable to prototype pollution because of inheritance, and because of this- multiple ways to exploit and defend against this specific kind of attack exist. Defending against this attack may require different approaches within different environments, but through modification, sanitization, maps, and proxies- we can make appropriate decisions on when and where to counter malicious attempts at object modification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e429ef77c3df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proxies in JavaScript: Mere Object Copycats or Heroes in Disguise?]]></title>
            <link>https://medium.com/@clairehap1/proxies-in-javascript-mere-object-copycats-or-heroes-in-disguise-98b0bd5cb011?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/98b0bd5cb011</guid>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[es6-proxies]]></category>
            <category><![CDATA[proxy-traps]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-proxy]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 13:51:44 GMT</pubDate>
            <atom:updated>2026-06-10T05:46:22.877Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine with me for a second that you have an object called person. You set the properties of name, age, hobbies and start to fiddle around with code. Something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*x_lIofbLkk--Kvv0vC30lg.png" /><figcaption>Bob is one heck of patient guy.</figcaption></figure><p>As developers, we can of course set things up properly… but JavaScript also allows us to set name, hobbies, and age to <em>anything</em>. This is not ideal if we strictly wanted an array full of hobbies, a real name, and an age that was in the realm of possibility. For our good pal Bob, we see what happens when his object is modified:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*I-Q56VHsa04aB7Y8ZUxvEA.png" /><figcaption>As you can see, poor Bob was modified and now our person object is not modeling him properly.</figcaption></figure><p>And as you sit there, staring at these incorrect values and contemplating which libraries to import to fix this… You may be wondering:</p><p><em>Is it possible with vanilla JavaScript alone to catch these errors?</em></p><p>Allow me to introduce: <strong>Proxies</strong>. Proxies are mimics, containers, and masters of blocking unwanted object manipulation. While tests allow for catching errors in hindsight, proxies <em>deny their very creation</em> by enforcing strict user-defined rules, something that sets them apart in a developer’s toolbox.</p><h3>What is a Proxy?</h3><p>Proxies are usually objects<em> </em>(and potentially also functions) that have the ability to wrap other objects. Wrapping is exactly what it sounds like- the object itself is being put inside of a container. There are two parts to a proxy:</p><ul><li>t<strong>arget</strong>: our object (potentially also a function) wrapped by the Proxy.</li><li><strong>handler:</strong> our handler will always be an object so that methods on it (called traps- which we’ll discuss shortly) can be accessed. These traps intercept operations and in essence- are used to implement rules that allow the proxy to protect our target.</li></ul><p>To give you a visual of the syntax, let’s use the person object from earlier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*tjsFFCwdQOm-7f99_llwyQ.png" /><figcaption>The basic syntax is fairly straightforward</figcaption></figure><p>Notice the syntax for accessing our proxy: it is <em>exactly </em>the same as accessing the object. They look the same and <em>are essentially interchangeable in all observable contents</em>.</p><p>This indistinguishable state is called <a href="https://www.pls-lab.org/Observational_Equivalence"><strong>observational equivalence</strong></a> and is achieved via the design pattern of<strong> </strong><a href="https://web.archive.org/web/20260302033255/https://2ality.com/2014/12/es6-proxies.html"><strong>transparent virtualization </strong></a><strong>. </strong>Per Dr. Axel Rauschmayer- because of this transparent virtualization (which makes it impossible to determine whether an object is a process or not) and the fact that a handler cannot be accessed via its proxy (<a href="https://web.archive.org/web/20260302033255/https://2ality.com/2014/12/es6-proxies.html"><strong>handler encapsulation</strong></a>), proxies are extremely efficient impersonators.</p><p>And it makes sense that a proxy can’t access its handler, after all- proxy instances <strong>do not have their own unique methods</strong>. But why? A proxy’s goal, as previously stated, is perfect mimicry. If it had access to methods that target did not- it would hardly look like the body double of the target object.</p><p>You might also be thinking of the keyword “new” used to invoke an object, and wondering perhaps if prototypes are involved. If a proxy had a parent creating it similarly to perhaps, a generator function, wouldn’t it be able to access its methods?</p><h3>Proxy() Constructor:</h3><p>As you may have guessed, the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#constructor">Proxy() Constructor</a> that makes our proxies is a factory function- so it is a built-in constructor and thus, our keyword new is producing instances of proxies.</p><p>While proxy instances don’t have unique methods, the Proxy constructor itself has one static factory method: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable">Proxy.revocable(target, handler)</a>. This creates a special, revocable Proxy that you can shut down (sending it to garbage collection at any time). It returns an object containing two things:</p><ul><li>The proxy itself and a revoke() function.</li><li>once you call revoke(), that specific Proxy instance becomes “dead.” Attempting to use it will throw a TypeError.</li></ul><p>Let’s check it out and see how it can help us tackle a situation when our secretAsHeckPassword becomes less-than-secret:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*2YkyVj9Am7uzQlWFceHMtw.png" /><figcaption>Maybe we should change the password to password1234.</figcaption></figure><h3>But Wait: Inheritance IS Happening!</h3><p>Our proxy, to achieve the ultimate goal of being identical to the target- is inheriting the target object’s prototype. How do we know this?</p><p>Because there exists exactly one scenario where a Proxy is not<em> just</em> an object: when the target is a function. When it wraps the target, it preserves the target’s original prototype chain and identity, and thus, inherits the Function.prototype.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*jHVrPZYiOxy0ddBAbk9L9w.png" /><figcaption>Seems we’ve solved the case!</figcaption></figure><p><em>Side Note: Building off of how unique proxies are- they’re also examples of </em><strong><em>exotic objects</em></strong><em>. Exotic objects differ from standard objects in that their internal methods have different implementations (read: they behave differently).</em></p><p><em>To be specific- how the proxy’s internal methods are connected to our handler traps sets it apart. It runs our code instead of simply referring to values stored within it. This is wildly different from how a standard object would behave. To give another example that is more familiar: </em><a href="https://blog.bitsrc.io/exotic-objects-understanding-why-javascript-behaves-so-moody-5f55e867354f"><em>Arrays are actually another type of exotic object</em></a><em>.</em></p><h3>Traps:</h3><p>While the proxy itself does not have methods, its handler object has thirteen methods called <strong>traps. </strong>These traps are methods that intercept operators. The two most frequently used are get() and set()- both are critical for retrieving and editing data. It’s important to note that each trap has default behavior to fall back on if nothing is explicitly provided.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy">Per MDN, all objects have the following internal methods:</a></p><ul><li>getPrototypeOf(): Looks up the object&#39;s prototype (the object it inherits from)</li><li>setPrototypeOf(): Changes the object&#39;s prototype. If it fails (e.g., creating a circular reference), it returns false.</li><li>isExtensible(): Checks if the object is allowed to have new properties added to it.</li><li>preventExtensions(): Marks an object as non-extensible so that no new properties can be added.</li><li>getOwnPropertyDescriptor(): Returns the &quot;Property Descriptor&quot; (the metadata like value, enumerable, configurable) for a specific property that exists directly on the object, ignoring the prototype chain.</li><li>defineProperty(): Creates or updates a property on the object, including its attributes (like making it read-only).</li><li>has(): Checks if a property exists on the object or anywhere in its prototype chain (used by the in operator).</li><li>get(): Retrieves the value of a property. If the property isn&#39;t on the object, it follows the prototype chain until it finds it or hits null.</li><li>set(): Writes a value to a property. If the property has a &quot;setter&quot; function defined, this method executes it.</li><li>deleteProperty(): Attempts to remove a property from the object.</li><li>ownKeys(): Collects a list of all own property keys (names) belonging to the object, including non-enumerable properties and Symbols.</li></ul><p>And if they are a function, can additionally access:</p><ul><li>apply(): The method executed when you invoke a function.</li><li>construct(): The method executed when you invoke a function using the new operator.</li></ul><h3>Intentional Errors vs. Invariant Violations:</h3><p>Traps can be used to throw various errors- but it’s important to keep in mind that there are two types of errors we as developers can receive working with proxies, to minimize confusion:</p><ul><li><strong>Intentional Errors</strong>: If you write an error intentionally while writing traps, to send back if someone tries to modify your target in a way you don’t allow- you’re sending back an intentional error.</li><li><strong>Invariant Violations:</strong> These are TypeErrors thrown by the JavaScript engine itself. If you write something that is literally impossible by the laws of JavaScript, you will be running into one of these as seen in the following code:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*ym99JvFMYr6oCvHHHKDoWQ.png" /></figure><h3>Hiding or Deleting References:</h3><p>Now that we’re getting to the end of proxy talk- you might be thinking:</p><p><em>All of this is interesting, but if we’re accessing the object through a proxy, can’t we bypass the security of the proxy itself by simply accessing the original object?</em></p><p>You’re definitely on to something- in professional code, once you create a Proxy, <strong>you often hide or delete the reference to the original object</strong> so that no one can accidentally access it directly.</p><p>Now hold on to that thought, because after Reflect we’ll handle some code pertaining to this-</p><h3>Reflect:</h3><p>I want to touch briefly on reflect, as Proxies and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect"><strong>Reflect</strong></a> are two sides of the same coin and designed to work together. Reflect provides a collection of methods which correspond exactly to the traps of the proxy handler. While Proxy traps allow you to intercept actions, Reflect methods allow you to execute their default behavior.</p><p>Reflect has become the standard instead of manually implementation, but why? There’s a few big reasons:</p><ul><li>Instead of needing to manually return Booleans, Reflect automatically returns the correct Booleans for failures and successes.</li><li>Reflect handles context of the keyword “this” automatically, ensuring it correctly points to the proxy and not the target.</li><li>The methods in Reflect are named exactly like the traps in Proxy (think back to our gator example). If you have a <strong>get</strong> trap, you use <strong>Reflect.get()</strong>. If you have an <strong>ownKeys</strong> trap, you use <strong>Reflect.ownKeys()</strong>. The more readable code is, the easier it is to maintain!</li></ul><p>Let’s go ahead and go back to good old Bob. We’re going to give him the proxy he deserves, and set him up with some of the cool things we learned about hiding our references and using Reflect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*HSYDhmFJUTOPZUbaMIhORg.png" /><figcaption>With this, our guy Bob is safe at last!</figcaption></figure><h3>So… Why Use Proxies?</h3><p>Without any importing of libraries, without anything besides vanilla JavaScript, we can accomplish monumental tasks using proxies:</p><ul><li><strong>Validation</strong>: Ensuring data remains valid- like making sure Bob has a normal age or a gator doesn’t have an impossible weight:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*7ojli0SZ7qIAZDV98Mkw_g.png" /></figure><ul><li><strong>Logging</strong>: Keeping a record of every change for debugging:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*JjXmWXMZUgzwVQYYBkjNng.png" /></figure><ul><li>D<strong>ata Binding</strong>: Automatically triggering UI updates when data changes (this is actually the backbone of frameworks like Vue.js!):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*BaPwCA_bDzy_T7OYSw9omg.png" /></figure><ul><li><strong>Lazy Loading</strong>: Fetching data from a server only when a property is actually requested:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*O9ZQwVzbLNPt9jsbrQMy5Q.png" /></figure><ul><li><strong>Security</strong>: Masking private properties or preventing unauthorized deletions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*bmlPEi2msPJ8X65PH7Rdgw.png" /></figure><p>With that broken down- all that’s left to do is to reflect on your growth and new found knowledge of proxies! Vanilla JavaScript they may be, but they are nothing short of extraordinary. Unsung heroes who wear disguises, protecting innocent objects from harm and saving developers like you and me from villainous errors of unknown and known origin alike.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98b0bd5cb011" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Generator Functions: Multiple Outputs, Multiple Case Uses]]></title>
            <link>https://medium.com/@clairehap1/javascript-generator-functions-multiple-outputs-multiple-case-uses-ab4769de7a52?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab4769de7a52</guid>
            <category><![CDATA[lazy-evaluation]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[generator-functions-in-js]]></category>
            <category><![CDATA[generator]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 08:53:09 GMT</pubDate>
            <atom:updated>2026-06-02T13:51:40.353Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the first concepts introduced to JavaScript beginners is the idea of data types. After learning about the <strong>primitive data types </strong>(Number, Bigint, String, Boolean, Undefined, Null and Symbol), I remember vividly diving into learning about <strong>complex data types</strong>: Objects, Arrays and of course, Functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/0*knmbsH9tsbWZdLG2.png" /><figcaption><a href="https://notesformsc.org/javascript-functions-overview/">I can’t tell you how many add function examples I saw as a new student!</a></figcaption></figure><h3>But what is a Function?</h3><p><strong>MDN</strong> defines a function generally as:</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions"><em>A “subprogram” that can be called by code either internally or externally.</em></a></p><p>Functions can have a name, return, and parameters optionally. They have a body wrapped in brackets (unless your arrow function spans one line) and always have a local (function) scope. They could be immediately invoked (IIFEs), could create closures (<a href="https://medium.com/@clairehap1/understanding-closures-through-telling-mad-lib-like-sagas-86d56cc39444">which I wrote on, for beginners</a>), could be constructors, could be helpers to a greater function, they could be function declarations or function expressions- but essentially, they’re highly flexible in what they can do and can help to manipulate data quickly and reliably.</p><p>Though functions return “function” when the <strong>typeof </strong>operator is used, functions have all of the abilities one would expect of an <strong>object</strong> (ex: they can be passed to other functions, assigned to variables, can become properties on objects, and can have properties and methods similar to any other object).</p><p>What sets them apart from other objects is their <em>ability to be called</em>, and functions themselves are referred to as <strong>first-class objects</strong> in JavaScript (not all languages allow this, for those curious).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*Mh_RWpDZduw7C51U" /><figcaption>It’s OK functions, JavaScript knows you deserve only the best!</figcaption></figure><p>JavaScript reads code from top to bottom and right to left, and the local scope of a function is not an exception to the rules of this <a href="https://developer.mozilla.org/en-US/docs/Glossary/Control_flow"><strong>control flow</strong></a>. Internally, hoisting occurs prior to code execution and when a function runs- it is generally understood that when called, a function will execute the entirety of the code within in it unless hitting an early return.</p><p>And this is where Generator Functions come into play- they defy the aforementioned norm of how most functions operate.</p><h3>What is a Generator Function?</h3><p>While most functions resolve to a singular output (or if they have no return, simply perform actions dictated by code within their bodies and then end)- a generator function has the ability to return multiple outputs. It can stop itself, unlike other functions that must run unless they hit a return. Perhaps even stranger, it can pick back up on a paused process and resume right where it left off.</p><p>Every generator function has inherited methods that come from the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction"><strong>GeneratorFunction </strong></a>object. Each and every generator function is actually a new instance of an object, also called a child, created by this parent. You might think that this sounds oddly familiar and for good reason- it’s an excellent example of <a href="https://launchschool.com/books/oo_javascript/read/prototypal_inheritance"><strong>Prototypal Inheritance</strong></a><strong>.</strong></p><p><strong><em>A bit of a sidebar:</em></strong><em> If you’re curious about how the structure of massive functions like the GeneratorFunction object looks, but slightly vexed that it’s not a global object and thus less easy to view- I highly recommend pulling up a console and plopping in the code:</em></p><pre>const GeneratorFunction = function* () {}.constructor;<br>const GeneratorPrototype = GeneratorFunction.prototype.prototype;<br>console.log(GeneratorPrototype);</pre><p><em>What you’ll see is a huge object full of methods! Take note of how each key is a string representing a method (here I’ve expanded the method </em><strong><em>next</em></strong><em>) and the values are invocations of the methods themselves:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I168mR3nZl8u8B-1ortp7g.png" /></figure><p><em>We use inherited methods frequently when we use syntax like this: </em><strong><em>ourThing.methodName() </em></strong><em>or perhaps to give you a more familiar example:</em></p><pre>// we use the methods provided via inheritance constantly<br>const array = [1, 2, 3];<br>// .slice() is a method located on Array.prototype<br>const slicedArr = array.slice(1);<br>// if you logged this on the console, you&#39;d see all the Array methods!<br>console.log(Array.prototype)</pre><p><em>While it’s also fun to scour source documents and you can technically find all of the details surrounding this object at</em><a href="https://github.com/v8/v8/tree/main/src/builtins"><em> v8/src/builtins on github if you just search the page for “generator”</em></a><em>, I find looking at the object itself to be more beneficial.</em></p><h3>Anatomy of a Generator Function:</h3><p>All generator functions are created <em>similarly</em> to functions, but with a few caveats. The first difference is that at declaration a star behind “function” designates them as a generator- it should be noted that while they can be initialized as values to variables, generator functions cannot be created with arrow syntax. Here are two examples of initialization:</p><pre><br>// Two ways to create generators, both equally excellent. <br>// Only difference between the two would be that the function <br>// declareYourself would be hoisted (and could be accessed <br>// before declaration) while expressoYourself would throw <br>// a ReferenceError stating it could not be accessed<br>// before initialization.<br><br>// function expression<br>const expressoYourself = function* () {<br>  yield &quot;mocha&quot;;<br>  yield &quot;latte&quot;;<br>  yield &quot;cafe au lait&quot;;<br>};<br><br>// vs function declaration<br>function* declareYourself() {<br>  yield &quot;I do declare!&quot;;<br>  yield &quot;Declaring that I am declaration!&quot;;<br>  // obligatory office quote<br>  yield &quot;I DECLARE BANKRUPTCY!&quot;;<br>}</pre><p>Let’s check out an example where we’re actually getting our yields returned to us: Here is a generator function, aptly named “generator” that’s going to give us multiple different values at different times:</p><pre>// function needs to be declared with *<br>function* generator() {<br>  // our various yields, to be sent back at different times<br>  yield &quot;woah there, send this back&quot;;<br>  yield &quot;also this, thanks!&quot;;<br>  yield &quot;don&#39;t forget this!&quot;<br>}<br><br>// set up a variable to the call of generator<br>// if you&#39;re curious as to why we&#39;ll talk logic in a minute<br>const gen = generator();<br><br>// each call is like turning a new page on a book,<br>// returning a completely different yield<br>console.log(gen.next().value) // =&gt; &quot;woah there, send this back&quot; <br>console.log(gen.next().value) // =&gt; &quot;also this, thanks!&quot;<br>console.log(gen.next().value) // =&gt; &quot;don&#39;t forget this!&quot;</pre><p>We see in the body of this function that we have multiple yields and you might be thinking, <em>“Yield is similar to return, but somehow we’re performing multiple returns and not exiting the function-</em>”</p><p>Then, looking down at our console logs (which contain what a correct method to recieve a value would look like) and seeing that instead of calling <strong>generator()</strong> directly with <strong>generator().next().value</strong> we’ve created a variable called <strong>gen</strong> to hold the invocation- you might be thinking, <em>“That seems a bit unnecessary, what if we cut that out and shortened the code?”</em></p><p>Let’s try it out, and see what happens-</p><pre>// function needs to be declared with *<br>function* generator() {<br>  // our various yields, to be sent back at different times<br>  yield &quot;woah there, send this back&quot;;<br>  yield &quot;also this, thanks!&quot;;<br>  yield &quot;don&#39;t forget this!&quot;<br>}<br><br>// ladies and gentlemen, we have a problem- but what is our problem?<br>console.log(generator().next().value) // =&gt; &quot;woah there, send this back&quot; <br>console.log(generator().next().value) // =&gt; &quot;woah there, send this back&quot;<br>console.log(generator().next().value) // =&gt; &quot;woah there, send this back&quot;</pre><p>You’ll notice we’ve appeared to hit some sort of snag. To figure out what’s happening, we need to know a bit more about how these functions function!</p><p>Reflect for a moment on how generator functions are instances. We made one instance, one <strong>gen , but what if there were other gens? </strong>Would they all return the same yield at the same time<strong>?</strong> Let’s find out:</p><pre>// function needs to be declared with *<br>function* generator() {<br>  // our various yields, to be sent back at different times<br>  yield &quot;woah there, send this back&quot;;<br>  yield &quot;also this, thanks!&quot;;<br>  yield &quot;don&#39;t forget this!&quot;<br>}<br><br>// lets create three instances of our generator function<br>const gen = generator();<br>const gen2 = generator();<br>const gen3 = generator();<br><br>// grab the first yield of the first instance<br>console.log(gen.next().value) // =&gt; &quot;woah there, send this back&quot; <br>// now the first yield of the second instance<br>console.log(gen2.next().value) // =&gt; &quot;woah there, send this back&quot;<br>// how about the second yield of the second instance?<br>console.log(gen2.next().value) // =&gt; &quot;also this, thanks!&quot;<br>// what if want EVERY yield from our third instance next<br>console.log(gen3.next().value) // =&gt; &quot;woah there, send this back&quot;<br>console.log(gen3.next().value) // =&gt; &quot;also this, thanks!&quot;<br>console.log(gen3.next().value) // =&gt; &quot;don&#39;t forget this!&quot;<br>// let&#39;s grab the last yield of the first instance<br>console.log(gen.next().value) // =&gt; &quot;also this, thanks!&quot;</pre><p>We can now see why our previous iteration of this code sent back our first yield three times- every time we called our generator function, it created a <em>completely new instance </em>and called it, but that instance was then immediately thrown away. We didn’t turn all of it’s metaphorical pages! We picked up <em>The Odyssey</em>, looked at one page, threw it away, picked up another copy of <em>The Odyssey</em>, looked at one page, <em>threw that copy away, </em>and then we picked up another one-</p><p>But in this new code, we’re saving each instance, we’re flipping through all the pages as we read, and we’re probably making all the people at the bookstore feel a lot less confused.</p><p>After we call our first instance and ask for the first value- we put it on pause. We look at our second instance and tell it to give us it’s first value. It pauses, but resumes when we ask for the second value- now we have a slightly deeper understanding of what’s going on under the hood. We just <strong>exited</strong> and <strong>re-entered</strong> our functions!</p><p>So far we’ve used:</p><ul><li>the<strong> yield </strong>keyword to pause execution and give us values.</li><li>the<strong> next()</strong> method to resume execution of our functions.</li></ul><p>We’ve received:</p><ul><li><strong>values</strong> accessed with .value (one of the two key/values on the entire object returned by generator functions).</li><li>the other key/value pair returned has a Boolean key called <strong>done</strong>, with a value of “true” or “false” depending on whether the generator is finished.</li></ul><p>That leaves the last two methods for generator functions:</p><ul><li><strong>return(), </strong>which ends a generator early and returns a specified value.</li><li><strong>throw(), </strong>which is used to throw errors.</li></ul><p>Let’s get into it!</p><p>The<strong> return() </strong>method allows for a forced completion of the generator function before all yields are returned.</p><pre>// we&#39;re creating an endless loop, intentionally for once!<br>function* endlessCount() {<br>  let count = 1;<br>  while (true) {<br>    yield `I BROUGHT YOU A NUMBER, IT&#39;S ${count}`;<br>   count++;<br>  }<br>}<br><br>// here we set our instance to counter<br>const counter = endlessCount();<br><br>// let&#39;s call it a few times!<br>console.log(counter.next().value); // =&gt; &quot;I BROUGHT YOU A NUMBER, IT&#39;S 1&quot;<br>console.log(counter.next().value); // =&gt; &quot;I BROUGHT YOU A NUMBER, IT&#39;S 2&quot;<br>console.log(counter.next().value); // =&gt; &quot;I BROUGHT YOU A NUMBER, IT&#39;S 3&quot;<br><br>// the generator is forced to stop with return, <br>// inside of object- we see that the value we return is our input string<br>// and the done Boolean has a value of true<br>// note: we did not use .done or .value so we recieve our full object<br>console.log(counter.return(&quot;STOP!&quot;)); // =&gt; { value: &#39;STOP!!&#39;, done: true }<br><br>// if we try to get our next value...<br>console.log(counter.next().value); // =&gt; undefined is returned<br>console.log(counter.next().done) // =&gt; and checking out our done Boolean returns true</pre><p>As you can imagine- this was the least traumatic infinite loop my computer has ever encountered. Because of the nature of generator functions pausing and then resuming- we don’t get the iconic page crash that makes computers weep and programmers panic.</p><p>Our last method, the throw() method, can be paired nicely with a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch"><strong>try…catch</strong></a> statement in order to catch specific errors that might otherwise be ignored by the computer. These errors display as errors<em> in the console</em>, which is incredibly useful:</p><pre>// function needs to be declared with *<br>function* generator() {<br>  // try is going to be attempting to run everything, if we get an exception, we go to catch<br>  try {<br>  // our various yields, to be sent back at different times<br>  yield &quot;nothing to see here&quot;;<br>  // this one will never run<br>  yield &quot;running sooooo smoothly!&quot;;<br>  // catch is going to give us back a message if something wrong happens<br>  } catch (error) {<br>    console.log(`ERROR in function generator! : ${error}`);<br>  }<br>}<br><br>// instance of our generator function<br>const gen = generator();<br><br>// grab the first yield of the first instance<br>console.log(gen.next().value) // =&gt; &quot;nothing to see here&quot; <br>// now the first yield of the second instance... wait a moment! .throw() threw an error!<br>console.log(gen.throw(&quot;whoopsies!&quot;).value) // =&gt; &quot;ERROR in function generator! : whoopsies!&quot;</pre><p>In more practical code- throw() can be used to raise exceptions <em>inside</em> the function when certain conditions are met. It’s function is very similar to, but should not be mistaken for <strong>t</strong><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw"><strong>he throw statement</strong></a>- which is widely available.</p><p>After seeing their syntax and methods- you might be wondering: why are generator functions a big deal? Alternatively, you might be wondering why you never hear more of them, particularly when it comes to JavaScript.</p><h3>Why Use a Generator Function?</h3><p>Generator functions initially saw heavy use in API requests, pairing with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"><strong>Promises</strong></a> and libraries (I’m going to make up a library called totallyRealLibrary for our Generator Function example) in order to create a better solution than the previous solution of AJAX and JQuery:</p><pre>// AJAX example:<br><br>// using var to fit in with the ES5 syntax<br>var targetUserId = 1;<br><br>$.ajax({<br>  url: &#39;https://JSONplaceholdertextImadeup.com/users/&#39; + targetUserId,<br>  success: function(user) {<br>    <br>    $.ajax({<br>      url: &#39;https://JSONplaceholdertextImadeup.com/posts?userId=&#39; + user.id,<br>      success: function(posts) {<br>        console.log(&quot;Got posts!&quot;, posts);<br>      },<br>      error: function(err) {<br>        console.error(&quot;Failed to fetch posts!&quot;, err);<br>      }<br>    });<br><br>  },<br>  error: function(err) {<br>    console.error(&quot;Failed to fetch user!&quot;, err);<br>  }<br>});<br><br>// Generator Function Example:<br><br>// generator functions can pause, imagine our <br>// fake library is checking for completed Promises<br>totallyRealLibrary(function* () {<br>  <br>  // we pause until user data is fetched<br>  const userResponse = yield fetch(&#39;https://JSONplaceholdertextImadeup.com/users/1&#39;);<br>  const user = yield userResponse.json();<br>  <br>  // we pause until posts are fetched<br>  const postsResponse = yield fetch(&#39;https://JSONplaceholdertextImadeup.com/posts?userId=&#39; + user.id);<br>  const posts = yield postsResponse.json();<br>  <br>  console.log(&quot;Got posts!&quot;, posts);<br>});</pre><p>While we’ve moved past that era, it’s worth noting that the behavior of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function"><strong>async/await</strong></a><strong> </strong>(the tools of the next era) produce a similar output to what developers were achieving when combining generators and promises.</p><p>Even more relevant is that async functions and generator functions have also been combined in the form of the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*"><strong>async function*</strong></a><strong> (</strong>also called an<strong> async generator). </strong>These functions are capable of handling massive amounts of data by breaking things down into smaller, more manageable sizes- think of<a href="https://jrsinclair.com/articles/2023/how-to-consume-a-paginated-api-using-javascript-async-generators/"> <strong>pagination</strong></a> for example (fetch this page, then this page, then this page-).</p><p>But the average generator function has its strengths too! They also excel at handling large datasets, are very memory efficient due to <strong>lazy evaluation </strong>(they only compute the next value exactly when you ask for it- think of my earlier infinite loop that was not-so-infinite in it’s impact), and the most interesting thought for me: they can be used to create <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators"><strong>custom iterables</strong></a><strong>.</strong></p><p>So not knowing what those were, I discovered quite on accident that you can use custom iterables in order to iterate over a tree:</p><pre>// we&#39;re going down my family tree today, yipee!<br>const myFam = {<br>  name: &quot;Lee&quot;,<br>  children: [<br>    {<br>      name: &quot;Michael&quot;,<br>      children: [{ name: &quot;Claire&quot; }, { name: &quot;Grant&quot; }, { name: &quot;Peter&quot; }]<br>    },<br>    {<br>      name: &quot;Kyle&quot;,<br>      children: [{ name: &quot;Jacob&quot; },  { name: &#39;Anderson&#39; }]<br>    }<br>  ]<br>};<br><br>// let&#39;s use a generator<br>function* traverse(node) {<br>  // yield the current person&#39;s name<br>  yield node.name;<br>  // if that person has children<br>  if (node.children) {<br>    // we use a for of loop to loop over the children<br>    for (const child of node.children) {<br>      // we pause and recurse down our tree to the next child<br>      // yield* will let us return individual names and <br>      // not an entire generator object- think of it as <br>      // being similar to flatten with arrays<br>      yield* traverse(child);<br>    }<br>  }<br>}<br><br>// now lets make myFam object iterable<br>// because I don&#39;t care if it&#39;s a tree-<br>// the heart wants what it wants<br><br>// myFam + [Symbol.iterator] is going to tell JavaScript:<br>// when we try to loop over myFam, use the following function<br>myFam[Symbol.iterator] = function* () {<br>  // we&#39;re going to have an instance of traverse run<br>  yield* traverse(this);<br>};<br><br>// and now, with our coding mischief managed:<br>// we can use for of loops over a tree<br>for (const person of myFam) {<br>  console.log(person); // =&gt; &quot;Lee&quot;<br>}                      // &quot;Michael&quot;<br>                       // &quot;Claire&quot;<br>                       // &quot;Grant&quot;<br>                       // &quot;Peter&quot;<br>                       // &quot;Kyle&quot;<br>                       // &quot;Jacob&quot;<br>                       // &quot;Anderson&quot;</pre><p>With my happy little tree being iterated over so smoothly, I can’t help but feel that Generator Functions have shown me a side of coding I had never seen before. If you told me before this post that functions could return multiple values? I would have told you that’s impossible. But now, I see the way generator functions works as fundamental to the evolution of not only my own growing knowledge, but to JavaScript itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab4769de7a52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive Into CPUs: From Silicon to x86 and ARM]]></title>
            <link>https://medium.com/@clairehap1/a-deep-dive-into-cpus-from-silicon-to-86x-and-arm-6d06ccf43db7?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d06ccf43db7</guid>
            <category><![CDATA[semiconductors]]></category>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[processors]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[cpu]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Mon, 25 May 2026 13:45:48 GMT</pubDate>
            <atom:updated>2026-05-28T02:16:23.984Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re new to programming- or even fairly experienced, but never had the burning desire to crack open your own computer because you’d rather <em>not</em> break it, you may have encountered terminology or concepts related to hardware that give you some pause.</p><p>As someone with a background in IT, I find questions seem to often intensify when CPUs are brought up.</p><p><em>Is a CPU is different than a GPU? Is CPU a semiconductor? Is it a chip or a system on a chip? Is it a microprocessor or a microcontroller? Is it the whole computer or the most important part? What is ARM? What is x86?</em></p><p>The more time you spend looking, the more questions you have.</p><p>I believe that a computer is inherently consistent on a logical level. If you dive into its components, you encounter many repeating concepts both with software and hardware. With that in mind, I made this for complete beginners looking to deep dive into knowledge of Central Processing Units, the architecture that shapes them, and all that surrounds and supports said CPUs. If you read it and find it interesting- I’ve attached links to subjects for further reading.</p><h3>Are CPUs Semiconductors?</h3><p>While occasionally used to refer to semiconductor devices- a <strong>semiconductor</strong> is<strong> </strong>more aptly described as a<strong> </strong>type of material. You may remember learning at some point about <strong>conductors</strong>- materials that allow heat or electricity to flow through them with ease. A great conductor of electricity and heat for example, is copper- commonly used in everything from wires to cooling components. An<strong> insulator</strong> is a material that does not conduct at all- think of rubber safety gloves and boots or plastic used as insulation on wires.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*zmmiom0aEsqYqkUd5ul8uQ.png" /><figcaption><a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/e-learning/discrete/chap1/chap1-1.html">Toshiba: What is a Semiconductor?</a></figcaption></figure><p>Given that the Latin word “<em>semi</em>” means “<em>half</em>”, “<em>partial</em>” or “<em>imperfect</em>”, we can deduct that it conducts somewhere in between an insulator and conductor. This property is very important- these materials can essentially be manipulated to be more conductible through a process called <strong>doping </strong>in order to ensure they conduct <em>only </em>where designers want them to, as I learned reading <a href="https://electronics.howstuffworks.com/diode.htm">an article </a>from Marshall Brain, a former professor at NCSU with a Master’s in CS.</p><p>Of all materials, the most common semiconductor is silicon (and it’s no surprise that its prevalence led to its immortalization in the moniker “Silicon Valley”).</p><p>Moving on from materials that make a CPU leads us to another burning question: How are they made?</p><h3>Glass, Light and Silicon: The Making of Chips</h3><p>Within a fab, engineers transform digital designs into glass templates called <strong>photomasks</strong> (often simply called masks) that will be used to produce a pattern on silicon with light- this process is called <strong>photolithography</strong>. (Micron Technology has an excellent <a href="https://www.micron.com/content/dam/micron/educatorhub/fabrication/photolithography/micron-fabrication-intro-to-photolithography-presentation.pdf">slideshow on the topic</a> if you want to go into further reading).</p><p>From here layers upon layers of circuits and devices are placed on silicon <strong>wafers</strong>. The end result is a wafer that holds up to thousands of individual chips. The wafers then are cut into the individual, small rectangular chips most people are familiar with- each of these are called a <strong>die</strong>, or <strong>computer chip</strong>, per <a href="https://newsroom.intel.com/tech101/what-are-semiconductors">Intel</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LlxjXrGE1_g6PyqC.jpg" /><figcaption><a href="https://en.wikipedia.org/wiki/Photolithography">Silicon wafer that has undergone photolithography</a></figcaption></figure><p>After being fabricated by a company like <a href="https://www.tsmc.com/english">TSMC</a> (one of the leading manufacturers of semiconductors in the world) silicon could become:</p><ul><li>a <a href="https://www.intel.com/content/www/us/en/products/docs/processors/what-is-a-gpu.html"><strong>GPU</strong> (Graphics Processing Unit)</a>, which focuses on handling the graphics, taking stress off a unit’s CPU. Commonly used in: machine learning, video editing, and gaming PCs.</li><li>a <a href="https://www.ibm.com/think/topics/field-programmable-gate-arrays"><strong>FPGA </strong>(Field-Programmable Gate Array)</a>, with configurable circuits. Commonly used in: Unmanned Aerial Vehicles, radar applications, industrial control systems like power grids and water treatment plants.</li><li>an <a href="https://www.arm.com/glossary/asic"><strong>ASIC</strong> (Application-Specific Integrated Circuit)</a>, which does one thing extremely efficiently. Commonly used in: Voice recognition, diagnostics and imaging systems in healthcare, cryptocurrency mining, AI and machine learning.</li><li><a href="https://www.ibm.com/think/topics/central-processing-unit">a <strong>CPU</strong> (Central Processing Unit)</a>, often called the “brain” of a computer. Commonly used in: PCs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*89x23vFBn5Kf046H" /><figcaption><a href="https://www.startpage.com/av/proxy-image?piurl=https%3A%2F%2Fnews-cdn.softpedia.com%2Fimages%2Fnews2%2FIntel-Officially-Intros-the-Core-i7-Processor-2.jpg&amp;sp=1779716616T2658ba85ecbfc36b57ab185dd43a9be20fff96aca9118aecb8b5fccdb1178159">An Intel i7 Processor</a></figcaption></figure><ul><li>many other <a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/e-learning/discrete/chap1/chap1-7.html"><strong>semiconductor devices</strong></a><strong>: </strong>processing units<strong> </strong>like<strong> </strong><a href="https://www.nist.gov/quantum-information-science/quantum-computing-explained"><strong>QPUs</strong></a><strong> </strong>(Quantum Processing Units), <a href="https://www.analog.com/en/lp/001/beginners-guide-to-dsp.html"><strong>DSP</strong></a><strong>s </strong>(Digital Signal Processor which handle analog), memory chips such as<strong> </strong><a href="https://www.lenovo.com/us/en/glossary/what-is-dram/"><strong>DRAM</strong></a><strong> </strong>(Dynamic Random-Access Memory), and <a href="https://www.ecb.torontomu.ca/~courses/coe838/lectures/Intro-SoC.pdf"><strong>SOCs</strong></a><strong> </strong>(System-on-a-Chip) which combine all normal components of a computer on to a single chip (CPU, memory, input, output, storage) and massively saves space, power and heat. <a href="https://insemitech.com/blogs/soc-vs-chiplets-architecture-which-one-is-the-future-of-semiconductor-design/">Though to be clear, SOCs and <strong>Chiplets</strong> are more accurately described as architectures.</a></li><li>semiconductor devices with a single purpose are called <a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/e-learning/discrete/chap1/chap1-7.html"><strong>discrete devices</strong></a><strong> (</strong>as oppose to those that are<a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/e-learning/discrete/chap1/chap1-7.html"><strong> integrated circuits</strong></a><strong> </strong>such as chips<strong>)</strong>, and include things like <a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/faq/diode/what-are-diodes.html"><strong>diodes</strong></a> and<a href="https://toshiba.semicon-storage.com/us/semiconductor/knowledge/faq/mosfet_common/what-is-a-transistor.html"> <strong>transistors</strong></a>. These devices are considered <a href="https://en.wikipedia.org/wiki/Logic_gate"><strong>logic gates</strong></a><strong>- </strong>a physical equivalent to the Booleans a developer like you or I might encounter while programming software. I would highly recommend diving into <a href="https://www.youtube.com/watch?v=gI-qXk7XojA">Crash Course’s <em>Boolean Logic and Logic Gates </em>video</a> for more information.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/0*A4ZWx_KY7YILWVFW.jpg" /><figcaption>Transistors</figcaption></figure><p>At this point, we’ve built up a good base knowledge and can start to define exactly what a CPU is.</p><h3>A CPU Is:</h3><ul><li>a central processing unit, the brain of the computer.</li><li>a semiconductor device make of silicon.</li><li>it is a microchip (also called a chip, a computer chip, an integrated circuit or IC) and the specific type of microchip is a <a href="https://www.asml.com/en/technology/all-about-microchips/microchip-basics"><strong>logic chip</strong></a>.</li></ul><p>It may <em>also</em> be called a <a href="https://www.ibm.com/think/topics/microprocessor"><strong>microprocessor</strong></a>, which is essentially a CPU on a single chip. Most CPUs today are microprocessors, but historically they were not one and the same. As technology has innovated over the years- CPUs have gotten more complex and shrunk in size dramatically. A microprocessor is defined mainly by the number of<strong> cores </strong>it supports- (<a href="https://www.ibm.com/think/topics/central-processing-unit">s<strong>ingle-core processors, dual-core processors, quad-core processors, and multi-core processor</strong></a><strong>s).</strong> Each core is its own processing unit, essentially giving you the power of multiple single-core CPUs. Cores are the heart of CPU and multiple cores allow it to handle many more processes simultaneously,<a href="https://www.cgdirector.com/cuda-cores-vs-stream-processors/"> though the processes may take longer to complete due to bandwidth limitations.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*-M83CHKsoyZ48-B0.jpg" /><figcaption><a href="https://www.cgdirector.com/cuda-cores-vs-stream-processors/">A summary of cores.</a></figcaption></figure><p>Now that we know the basic definition, we can dive into individual components. A CPU, like a brain- handles a lot of different functions simultaneously that keep the rest of the system up and running, putting the rest of the “body” (in this case, your PC’s components) to work.</p><p>Per <a href="https://www.ibm.com/think/topics/central-processing-unit">IBM</a>, the components within a PC include:</p><ul><li><strong>a control unit:</strong> a task assigner, the delegator of all things to do.</li><li><strong>an arithmetic/logic unit:</strong> (ALU)- all math is handled by this unit.</li><li><strong>a memory unit</strong>: handles memory usage and managing data flow between its boss the CPU and <strong>memory</strong> (also called <strong>RAM</strong>, more on this in a bit).</li><li><strong>a cache</strong> - the cache is the middle man accessing memory on behalf of the CPU.</li><li><strong>registers</strong> : a form of permanent memory made for incredibly quick access by the CPU- it holds the numbers that instructions work off of.</li><li><strong>a clock:</strong> synchronizes the CPU, coordinating components via electric pulses. the rate of pulse delivery is referred to as clock speed. If you’ve ever heard of the term of <a href="https://www.corsair.com/us/en/explorer/glossary/what-is-overclocking/"><strong>overclocking</strong></a>- this increases the internal clock rate of the CPU beyond rated speed. It tends to dramatically increase performance in the moment, but can also run the risk of damaging the device.</li><li><strong>an instruction and register pointer: </strong>essentially ensures smooth transition from one instruction to execute to another for the CPU.</li><li><strong>buses: </strong>ensure proper data transfer to occur between components.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*FQSkKkEPLfGWf-xm" /><figcaption><a href="https://storage.googleapis.com/dkmtbowqwutdoe/memory-hierarchy-design-in-computer-architecture.html">The Speed of Registers and Cache Visualized</a></figcaption></figure><p>It is also worth noting that your CPU interacts heavily with <strong>storage</strong> and <strong>memory</strong>. While the two words are often used to describe each other, they represent <a href="https://www.hp.com/us-en/shop/tech-takes/computer-memory-vs-storage">two <em>distinct </em>concepts</a>:</p><p><strong>Memory</strong> is not stored- while very fast, it cannot retain things. Instead all it “knows” is temporary. The moment the PC loses power, it loses access to memory.</p><ul><li><strong>RAM</strong> (Random-Access Memory) is the “main” memory of your PC that the CPU uses for tasks. It is like a person’s short term memory, and is also called “volatile memory”. Most PCs shipped straight out of the factory will have either 16GB or 32GB of RAM.</li><li><strong>ROM</strong>- (Read-Only Memory) is non-volatile, the best way to define<br> it would be to consider something so integral- you’re born with it. It comes from the factory with your PC and is written during the manufacturing process. If you’ve ever heard of your BIOS or owned a game cartridge from a Sega Genesis or Gameboy- you’ve seen ROM in action. For a CPU, the ROM would hold it’s firmware.</li></ul><p><strong>Storage</strong> is much slower than memory, but the trade off is that it is non-volatile. That is- it will retain a large amount of saved information, similar to long term memory. The drives on your computer (C: drive, for example) are examples of storage. The size of storage is much larger than RAM- think of at least 200GBs. In 2026 TBs (terrabytes) of storage are not uncommon on high to medium end PCs. When you request a program to launch via a click , your CPU will communicate with the storage to retrieve the information needed for the request.</p><ul><li><a href="https://aws.amazon.com/compare/the-difference-between-ssd-hard-drive/"><strong>SSDs</strong></a> (solid state drives) have faster read/writes than HDDs and are the standard for high performance PCs such as gaming desktops.</li><li><a href="https://aws.amazon.com/compare/the-difference-between-ssd-hard-drive/"><strong>HDDs</strong></a> (hard disk drives) do also exist still- they can offer very large storage capacities at a low price per terabyte (which is why they’re still around).</li></ul><h3>ARM And x86</h3><p><strong>Instruction Set Architectures </strong>like ARM and x86 help a CPU understand given instructions. ARM and x86 both have the same task, but they handle it in very different ways.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Utm18AmB6e8b1K0S" /><figcaption><a href="https://blog.csdn.net/qq_14829643/article/details/139580171">Two Architectures: Two Solutions</a></figcaption></figure><p><strong>x86</strong> was created in 1978 by Intel and has been a force in the industry for 45 years. Their first chip was the Intel 8086 and every chip from Intel and AMD is it’s descendent. Intel naming the architecture x86 is a reminder of this original Intel 8086 chip.</p><ul><li>it uses a <strong>CISC</strong> instruction set (Complex Instruction Set Computing).</li></ul><p>CISC is named as such because it executes complex multi-step operations with a single instruction- while this may seem minor, moving data between between different areas of memory is no small task and requires several complicated instructions. x86 helps to simplify this(to a degree). It has over 1,500+ Instructions, though many are rarely used.</p><p>A defining feature is its backwards compatibility, which is both a strength and weakness. Each chip runs software from the one before it and <em>in theory </em>software written for an Intel 8086 could run on an i9.</p><p>Design wise- within an x86 system: sound, graphics cards, memory, storage, and the CPU–are all independent of each other. Components can be changed or expanded without affecting connectivity or the overall hardware platform.</p><p>It has high power consumption, but it&#39;s PSU benefits from significantly increased performance. Its power draw clocks in at around 65W-250W TDP. You can find it inside of:</p><ul><li>desktop PCs using Intel Core and AMD Ryzen chips</li><li>data centers</li><li>cloud servers</li></ul><p><strong>ARM</strong> was created in 1985 by Acorn Computers, a British company and it’s name comes from the company that made it: A(corn) R(isc) M(achine).</p><ul><li>It uses a RISC instruction set (Reduced Instruction Set Computing).</li></ul><p>RISC breaks everything into simpler steps. It does less per instruction, and instead seeks to increase speed and use less power. RISC aimed to shave what it saw as bloat from x86, and have only the instructions that tended to be used and none of those that were hardly used (if ever) for a total of 200–300 Instructions.</p><p>Unlike Intel or AMD CPUs, there is no ARM processor manufacturer. Instead, Arm Holdings licenses chip designs to other hardware manufacturers which then incorporate the ARM processor chip into their hardware designs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*GlPqtpnhygGDxooQ3W7QKQ.png" /><figcaption>Note that ARM is listed in Design while Intel is under Integrated Device Manufacturers</figcaption></figure><p>ARM chips are not interchangeable and are more application specific (so, while they are built for their specific device- they can&#39;t really be used for other devices). Their CPU is on one chip with other components. It&#39;s SOC (System on a Chip) contains the CPU alongside the GPU, RAM, and other controllers on a single chip. While ARM produces a huge quantity of chips for various devices, design wise their chips are running into an inevitable issue- when reducing size brings innovation, you hit an inevitable wall- since size is finite. <a href="https://semiengineering.com/from-monolithic-socs-to-chiplets-a-new-hardware-security-paradigm/"><strong>Chiplets</strong></a> (a more modular architectural design used by x86) may have a leg up because of their flexibile architecture.</p><p>In addition to being compact- their power usage clocks in at only 1W-15W TDP. If you own a device running on a battery or that is very small- likely it’s running ARM. Low power means low battery consumption and thus, incredibly high battery life. Overheating becomes a minimal issue and fans are not needed or needed minimally- which saves enormous amounts of space. Because of this you can find ARM chips within:</p><ul><li>phones like iPhones and Androids</li><li>smaller devices like iPads, apple watches, WIFI routers, and raspberry PIs</li><li>Apple computers like MacBook Air, MacBook Pro, iMac, Mac Mini, and Mac Pros</li><li>smart TVs</li></ul><p>When the Apple M Series chip launched in 2020, running not x86, but ARM- it was a major shock to a tech world that had underestimated ARM chips. These chips massively outperformed x86 chips both in terms of performance and power- laptops were lasting 15 to 18 hours on a charge.</p><p>The potential wowed businesses and Amazon has deployed their own ARM-based Graviton processors in their data centers to take advantage of these traits. They claim they are 40% at price-performance. Less power needed translates directly to a lower cost at scale. It has also attracted Meta, <a href="https://thenextweb.com/news/meta-amazon-graviton-chips-agentic-ai">who recently signed a deal with Amazon</a> in order to attempt to provide chips for the surge in compute they’re seeing due to AI.</p><p>As last note on ARM- I wanted to show an example of Assembly language, to provided some insight into what it looks like to write when compared to computer language (aka binary) and languages learned by programmers (in this case, C) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*0js-zETUsh9xS3TSv5vuPA.png" /><figcaption><a href="https://www.cs.sfu.ca/~ashriram/Courses/CS295/assets/books/HandP_RISCV.pdf">Computer Organization and Design RISC-V Edition: The Hardware Software Interface</a></figcaption></figure><h3>Career Path Most Directly Related to This:</h3><p><strong>Embedded Engineering:</strong></p><p>If you’re interested in engineering that involves the development and testing of software for basically anything from an airplane to a pacemaker- embedded might be what you&#39;re looking for. Focus for study should be: operating systems, programming models, communication protocols (wired interfaces, wireless and IoT), <a href="https://embedded.fm/blog/2016/2/27/embedded-software-engineering-101-microcontroller-basics"><strong>microcontrollers</strong></a> (smaller PCs), lower level languages like C, C++, <a href="https://www.reddit.com/search/?q=embedded+Rust+programming&amp;cId=94693534-2ca1-4c46-84bf-688534535b50&amp;iId=793be078-ae5f-43e8-87ec-a70fcfc77e9a">Rust</a> and Assembly (pictured above), learning hardware schematics and basic electronics, hardware debugging, and much more- an exhaustive list can be found <a href="https://cranesvarsity.com/essential-technical-skills-for-embedded-systems-engineers-in-2026/">here.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*ah5gzbiyTBoISRZG.jpg" /><figcaption><a href="https://www.mothersontechnology.com/en-us/services/dex/embedded-engineering/">This could be you!</a></figcaption></figure><h3>Who is Hiring?</h3><p>Here is a list of different companies across industries presently seeking embedded engineers:</p><ul><li><strong>Qualcomm</strong> — Chip manufacturer / Semiconductors</li><li><strong>Advanced Micro Devices (AMD)</strong> — Chip manufacturer / Semiconductors</li><li><strong>Raytheon</strong> — Defense / Aerospace</li><li><strong>Boeing (Millennium Space Systems)</strong> — Aerospace / Defense</li><li><strong>Northrop Grumman</strong> — Defense / Aerospace</li><li><strong>Innovative Defense Technologies (IDT)</strong> — Defense / Military software</li><li><strong>Toyota Material Handling</strong> — Automotive / Heavy machinery</li><li><strong>Rockwell Automation</strong> — Industrial automation</li><li><strong>Ford Motor Company</strong> — Automotive</li><li><strong>Bose</strong> — Consumer electronics / Audio hardware</li><li><strong>Philips</strong> — Medical devices / Healthcare tech</li><li><strong>Valeo</strong> — Automotive supplier</li><li><strong>MITRE</strong> — Defense / Aerospace / R&amp;D contracting</li><li><strong>Rivian</strong> — Automotive / Electric vehicles</li><li><strong>Honeywell</strong> — Aerospace / Industrial conglomerates</li><li><strong>Motorola Solutions</strong> — Telecommunications / Public safety hardware</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d06ccf43db7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Closures Through Telling Mad-Lib Like Sagas]]></title>
            <link>https://medium.com/@clairehap1/understanding-closures-through-telling-mad-lib-like-sagas-86d56cc39444?source=rss-75c39b3627b9------2</link>
            <guid isPermaLink="false">https://medium.com/p/86d56cc39444</guid>
            <category><![CDATA[javascript-closure]]></category>
            <category><![CDATA[closures-in-javascript]]></category>
            <category><![CDATA[closures-functions]]></category>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[functions-in-javascript]]></category>
            <dc:creator><![CDATA[Clairehap]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 00:53:06 GMT</pubDate>
            <atom:updated>2026-04-29T04:21:58.620Z</atom:updated>
            <content:encoded><![CDATA[<p>How did one thought about closures end up in creating the Saga Creator seen below? (Or, if you’re on mobile- check out the CodePen <a href="https://codepen.io/ClaireHappel/pen/gbLYWZe">here</a>!) Well- it’s a long story, but I’m glad you asked-</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FClaireHappel%2Fembed%2Fpreview%2FgbLYWZe%3Fdefault-tabs%3Djs%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DgbLYWZe&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FClaireHappel%2Fpen%2FgbLYWZe&amp;image=https%3A%2F%2Fshots.codepen.io%2Fusername%2Fpen%2FgbLYWZe-512.jpg%3Fversion%3D1777338121&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/827b42b6a8335b9b71bcfe9a6574378c/href">https://medium.com/media/827b42b6a8335b9b71bcfe9a6574378c/href</a></iframe><p>When I first saw a closure used, it felt like it flew in the face of everything my newbie-programmer self knew (a common experience while learning).</p><p>Scope to me was a simple thing: long ago during the dawn of ES6, JavaScript programmers received let and const to address some of the issues experienced with var. Var could be redeclared, but neither let nor const could be. And of the two, const could never be redefined. Unlike var- variables declared by let and const could not be accessed before the code execution reached the line they were declared on (creating something called a temporal dead zone).</p><p>Take these concepts and mix it in with the idea that when something is locally scoped in a function, it cannot be accessed in the global scope- and you can see why initially, I struggled with the idea of a closure. At first glance- it seemed to defy to strict scoping rules I knew. How in the world could we possibly use an inner fuction to pass on the values of variables from an inner scope?</p><p>The answer, dear reader- is the closure. Per <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Closures">MDN</a>, “A <strong>closure</strong> is the combination of a function bundled together (enclosed) with references to its surrounding state (the <strong>lexical environment</strong>). In other words, a closure gives a function access to its outer scope. In JavaScript, closures are created every time a function is created, at function creation time.”</p><p>As a visual learner, I decided that the best way to tackle this was to create some sort of side project, and I was enamored with an idea presented in my class that involved generating a series of random sagas.</p><p>How hard could it be? I knew I’d need some sort of container for random variables within my function- and quickly settled on arrays that would exist within my <strong>newSaga</strong> function, since I knew the array elements would be easy to access with their indexes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zo1w07hwAl7iI3qYIZKKjw.png" /><figcaption>As you can see, I had a bit of fun with the names.</figcaption></figure><p>And of course, we would also need some sort of randomization function to pull from our lovely arrays of strings- a classic <strong>Math.random()</strong> implementation seemed like a great idea:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*OjitEMbJ6l9sj-Sk6fWLNA.png" /><figcaption>Math.floor() and Math.random() are a gift from the heavens above, and the butter to my bread</figcaption></figure><p>Then we need an inner function, one that both creates our mad-libs style sentence and returns it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JiB2y6-yTethd7RgxTbFLA.png" /><figcaption>Simple, sweet, and to the point.</figcaption></figure><p>And just like that- our <strong>newSaga</strong> function was built! I took a moment to bask in all of its glory. Not only was I using closure to pass on the value of all the various elements within my arrays- I had also created a function within a function that was using closure to pull the value of another function,<strong> random()</strong>. And the more I thought about it, the more it made sense. Whenever this function was called- of course every value would be evaluated and resolved- this is one of the most basic concepts of programming and one of the first things I learned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SbUvLYBFFK3fdUAqNjQgew.png" /><figcaption>I do so love when a good function comes together.</figcaption></figure><p>I think seeing how the call for this <strong>newSaga</strong> function works really tied it all together for me, I’ve added a console.log that illustrates the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9oZ1_Ac584AIfUsNn_beHQ.png" /></figure><p>We receive our data correctly calling <strong>newSaga()() (t</strong>he second set of parentheses are needed to immediately execute the returned inner function). We’re using the closure and call to access values we would never be able to access globally. This is the power of closure!</p><p>Notice how here there are no arguments or parameters- if there were, we might hit on another fascinating concept: currying. To explain it briefly, currying breaks down one parent function with many arguments into a series of child functions- with each child handling one of those arguments. For more info on that- I highly recommend: “ <a href="https://medium.com/@linz07m/currying-functional-programming-made-simple-0331c01c1746">Currying: Functional Programming Made Simple</a>”, by Lince Matthew. Closures are often used to implement currying, so I highly recommend learning about one when you’re learning about the other.</p><p>Fascinating detours aside- I realized that since there’s a lot of visually inclined people like me in the world, they might benefit from having not just all this lovely code, but some sort of functionality they can see.</p><p>And so my project expanded into the world of CSS and HTML, seeking to implement something minor that showed in real time the importance and value of closures-</p><p>The first step was to get some HTML fleshed out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*-CgX89ZJH_4ymvJk5jNYkw.png" /><figcaption>Just some basic stuff!</figcaption></figure><p>And from here, the major changes to our JavaScript were pretty straightforward:</p><ul><li>We made sure that our “sagaOutput” id from the above HTML got the data from <strong>const saga </strong>sent to it safe and sound.</li><li>We attach our closure to our “generateBtn” id and add the click functionality. Our function is passed as a callback to the event listener- meaning when we click our “generateBtn”, we’ll get the data from a brand new saga placed before us.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XocKuhdf9V4GcU4vyXR2Dg.png" /><figcaption>New and improved!</figcaption></figure><p>Looking at the final result- I was struck by a sense of how incredibly useful it was to have the <strong>encapsulation</strong> a closure provides<strong> </strong>— that is, my variables for saga need never fear any change since they are only accessible within the function. Even if I created a whole brand new set of variables for <strong>random, names, adjectives, titles, objects, adverbs, people, actions,</strong> and <strong>terrors</strong>… Even if they were all <strong>consts</strong>… Even if they were all in the global scope (the highest scope available). Not a thing would change-</p><p>Because closures don’t defy scope, they epitomize it.</p><p>In the last bit of my project stretch, I styled up the page with some CSS. I made it look nice for anyone looking to do something similar. Here’s the final result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*kE0w1ozdLuMfNl8sggfW1w.png" /></figure><p>And so the saga of a Saga Creator made by a “Saga Creator” creator reached its end with a very visual representation of the power of closures.</p><p>As a last sign off- Feel free to check out or play with the code using the CodePen link at the top of the page, or use it to make your own saga- may it aid you in your own learning quest!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86d56cc39444" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>