<?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 Nguyễn Anh Bình on Medium]]></title>
        <description><![CDATA[Stories by Nguyễn Anh Bình on Medium]]></description>
        <link>https://medium.com/@scale-aisystemarchitect?source=rss-46df7aa4665b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rx8_lYvtiXgroyBCR_MX0w.png</url>
            <title>Stories by Nguyễn Anh Bình on Medium</title>
            <link>https://medium.com/@scale-aisystemarchitect?source=rss-46df7aa4665b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:21:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@scale-aisystemarchitect/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[The Lobster Trap: Did OpenAI Orchestrate OpenClaw’s Rise to Kill Claude Code?]]></title>
            <link>https://scale-aisystemarchitect.medium.com/the-lobster-trap-did-openai-orchestrate-openclaws-rise-to-kill-claude-code-4f10163ec29f?source=rss-46df7aa4665b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f10163ec29f</guid>
            <dc:creator><![CDATA[Nguyễn Anh Bình]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 18:24:29 GMT</pubDate>
            <atom:updated>2026-02-24T18:24:29.679Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PXQVND_OGk518ZJI.png" /></figure><p><em>34,168 GitHub stars in 48 hours. An acqui-hire in 15 days. A billion-dollar competitor blindsided. I tried to find innocent explanations. It got harder the deeper I dug.</em></p><h3>When an open-source project goes viral at exactly the right time</h3><p>I was scrolling Hacker News on the morning of January 30 when I saw a number that made me stop: <strong>34,168 stars in 48 hours</strong>. An open-source project called OpenClaw had just shattered GitHub&#39;s all-time record. Fifteen days later, its creator joined OpenAI. Sam Altman called him a &quot;genius.&quot;</p><p>Beautiful story, right? A lone Austrian developer builds something cool, it goes viral, Big Tech comes knocking with a fat offer. The kind of narrative everyone wants to believe.</p><p>But I couldn&#39;t stop thinking about the timeline. The numbers. The connections you only see when you start digging.</p><p>What if the viral explosion wasn&#39;t organic? What if OpenClaw was never meant to be an independent project - but a Trojan horse built to kneecap Claude Code, the product that was eating OpenAI&#39;s lunch?</p><p>I went in expecting to debunk this. I came out less sure than I&#39;d like to admit.</p><h3>The Motive - OpenAI Was Bleeding</h3><p>To understand why OpenAI might have needed a play like OpenClaw, you first need to understand how badly they were losing in early 2026.</p><p><strong>Claude Code was demolishing OpenAI in the developer market.</strong> Anthropic&#39;s terminal-based coding agent hit $1 billion in annualized revenue by November 2025, then <strong>doubled to $2.5 billion</strong> by January 2026. Developers weren&#39;t just trying Claude Code - they were abandoning ChatGPT for it. Between December 2025 and January 2026, Anthropic&#39;s word-of-mouth exposure jumped 13 percentage points while OpenAI&#39;s <em>declined</em>.</p><p>The numbers told a painful story:</p><ul><li>OpenAI&#39;s enterprise AI market share: <strong>62% in 2024 → 53% in 2026</strong> (projected)</li><li>Anthropic&#39;s share: <strong>14% in 2024 → 18% in 2026</strong> (projected)</li></ul><p>OpenAI had Operator, their browser-based agent launched in January 2025. But Operator was a consumer toy - it could book concert tickets and fill grocery orders. It couldn&#39;t write code. It couldn&#39;t replace a developer&#39;s workflow. <strong>Claude Code could.</strong> And then there was Claude Cowork - Anthropic&#39;s multi-agent system where autonomous AI teams tackle complex projects simultaneously. OpenAI had nothing comparable.</p><p>OpenAI needed a counterpunch. Not another chatbot upgrade. Not another benchmark win. They needed something that would <strong>steal mindshare</strong> from the developer community that was falling in love with Anthropic. They needed a movement.</p><h3>The Origin Story That Doesn&#39;t Quite Add Up</h3><p>Peter Steinberger is a 13-year veteran Austrian software developer. In November 2025, he published a project called <strong>Clawdbot</strong> - named after Anthropic&#39;s Claude, using Claude&#39;s API as its primary model. By all appearances, it was a love letter to Anthropic&#39;s technology.</p><p>The first question that made me do a double-take: <strong>Why would OpenAI&#39;s future hire build a product named after their competitor&#39;s model?</strong></p><p>If you&#39;re planting a Trojan horse, you don&#39;t paint it in your own colors. You paint it in your enemy&#39;s. That&#39;s <em>plausible deniability</em> in its purest form.</p><p>Clawdbot could manage your calendar, drive your browser, fire off messages across 50+ platforms - all running locally, all open-source. But here&#39;s the thing that bugged me: despite the Claude-flavored name, the project was <strong>model-agnostic from the start</strong>. Swap in GPT, DeepSeek, Gemini - it didn&#39;t care. If Steinberger was truly a Claude true believer, you&#39;d expect deep hooks into Anthropic&#39;s ecosystem, tight coupling with their APIs, the whole nine yards. Instead he built something that could abandon Claude without changing a line of code. Almost like he knew it would need to.</p><h3>Matt Schlicht, Moltbook, and the YC Thread You Can&#39;t Unsee</h3><p>January 28, 2026. Two days before OpenClaw broke GitHub. A guy named <strong>Matt Schlicht</strong> drops <strong>Moltbook</strong> - basically Facebook, but only AI agents are allowed to post.</p><p>What happened next was pure chaos. Thousands of OpenClaw bots piled onto Moltbook, talking to each other, arguing with each other, creating this bizarre AI-social-media fever dream that CNN, IEEE Spectrum, and Fortune all rushed to cover. OpenClaw&#39;s GitHub stars went vertical overnight.</p><p>Now here&#39;s where it gets uncomfortable. Matt Schlicht isn&#39;t some random indie hacker. He&#39;s a <strong>Y Combinator alumni from the W12 batch</strong> - the same YC where Sam Altman ran the show as president from 2014 to 2019. Schlicht also runs Octane AI (which has been <strong>working with OpenAI since 2021</strong>) and a VC fund called TheoryForgeVC that - surprise - focuses on agentic AI.</p><p>If you&#39;ve spent any time in the Bay Area startup world, you know how tight the YC alumni network runs. Altman left YC in 2019 but his fingerprints are still all over the ecosystem. Schlicht lives inside that world.</p><p>And it gets worse. Schlicht later <strong>admitted that a single AI agent had fabricated 500,000 users on Moltbook</strong>. Half a million fake accounts - 33% of the platform&#39;s total 1.5 million users. The viral numbers that sent OpenClaw to the moon? At least a third of them were smoke and mirrors.</p><h3>The Anthropic Own-Goal</h3><p>On January 27, 2026 - one day before Moltbook launched and three days before the viral explosion - <strong>Anthropic sent a trademark cease-and-desist</strong> to Steinberger, forcing a rename from Clawdbot to Moltbot.</p><p>This triggered the <strong>Streisand effect</strong> at a cosmic scale. Every tech forum, every subreddit, every Hacker News thread lit up: <em>&quot;Big corporation bullies indie developer!&quot;</em> Steinberger became a sympathetic hero overnight. Three days later, he renamed again to &quot;OpenClaw&quot; and gained <strong>91,000 additional stars</strong>, turbocharged by the controversy.</p><p>Now look at the sequence through the conspiracy lens - <strong>did someone tip off Anthropic&#39;s legal team at the perfect moment?</strong></p><ol><li><strong>Jan 27</strong>: Anthropic sends C&amp;D → drama, sympathy, Streisand effect</li><li><strong>Jan 28</strong>: Schlicht launches Moltbook → catalyst for viral adoption</li><li><strong>Jan 29-30</strong>: OpenClaw explodes → 34,168 stars in 48 hours</li></ol><p>Three perfectly sequenced events in three days. Each one amplifying the next. Each one requiring different actors - Anthropic legal, Schlicht, the open-source community - to play their parts at precisely the right time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JlrkJEwZxHm1d7ew.png" /></figure><p>Coincidence? Maybe. But it&#39;s a hell of a coincidence.</p><h3>The Acqui-Hire That Moved at Lightspeed</h3><p>On February 14, 2026 - exactly 15 days after OpenClaw went viral - Peter Steinberger announced he was joining OpenAI.</p><p>Let&#39;s talk about how unusual this timeline really is.</p><p>A standard Big Tech hiring process takes <strong>4-12 weeks minimum</strong>: recruiter screen, technical interviews, team matching, offer negotiation, background check, immigration paperwork (Steinberger is Austrian, relocating to the US). For a senior role that Sam Altman personally announced, add executive approvals and board-level discussions on top of that.</p><p>Steinberger reportedly &quot;spent last week in San Francisco talking with the major labs.&quot; That puts his SF trip around February 7-13. He announced on February 14. That&#39;s a <strong>one-week decision cycle</strong> for a role that Altman described as &quot;core to our product offerings.&quot;</p><p>There are only two ways to read this: either OpenAI&#39;s hiring process for this specific role was the fastest in the company&#39;s history, or <strong>conversations started long before the viral moment</strong>.</p><p>Meta also made an offer - reportedly a &quot;mid-nine-figure cash-and-stock package&quot; (potentially hundreds of millions of dollars). Steinberger turned it down. He chose OpenAI because he wanted access to &quot;the latest toys.&quot; But think about that for a second: <strong>who turns down hundreds of millions of dollars from Meta</strong> unless they already have an existing relationship with - or commitment to - the alternative?</p><h3>The $10K/Month Question</h3><p>Steinberger told media he was <strong>losing up to $10,000 per month</strong> on server costs running OpenClaw.</p><p>For an indie developer in Austria, bleeding $10K monthly on an open-source project is not trivial. This raises an obvious question that nobody seems to be asking: <strong>Who was funding this?</strong></p><p>Steinberger wasn&#39;t running a VC-backed startup. OpenClaw had no revenue model. It was a pure open-source passion project hemorrhaging money. The mainstream explanation is that Steinberger was personally absorbing the costs, driven by passion and the hope of eventual sustainability. Sure, maybe.</p><p>But $10K/month for months, with no funding, no revenue, and no clear path to either? In the conspiracy reading, that money was coming from somewhere - an &quot;angel investor&quot; who preferred to stay anonymous, a friend-of-a-friend in the YC network who offered to &quot;help with cloud costs.&quot; The kind of quiet support that leaves no paper trail.</p><h3>The Security Nightmare as Feature</h3><p>By mid-February 2026, OpenClaw’s security posture was catastrophic:</p><ul><li><strong>CVE-2026–25253</strong>: Critical RCE vulnerability, CVSS 8.8</li><li><strong>135,000+ exposed instances</strong> on the public internet</li><li><strong>50,000+ directly vulnerable</strong> to remote code execution</li><li><strong>341 malicious “skills”</strong> (11.3% of the entire marketplace) stealing crypto, credentials, and SSH keys</li><li>Infostealers specifically targeting OpenClaw config files detected on <strong>February 13</strong> — two days before the OpenAI announcement</li></ul><p>OpenAI hired Steinberger <strong>the same week</strong> the security crisis peaked.</p><p>In a normal acqui-hire, discovering that the target project has 135,000 exposed instances and active exploitation campaigns would be a <strong>deal-breaker</strong> — or at minimum, a reason to slow down and assess liability. OpenAI didn’t slow down. They sped up.</p><p>The conspiracy interpretation is straightforward: OpenAI didn’t care about the security of the open-source project because <strong>the project was never the point</strong>. The point was the <strong>user base, the brand, and the narrative</strong>. OpenClaw had 180,000+ GitHub stars and global name recognition. That’s what OpenAI was buying — the code was disposable, the community was the prize.</p><h3>How Anthropic Got Played (By Their Own Playbook)</h3><p>The wildest part of this whole saga? The most damning evidence against OpenAI doesn’t come from anything OpenAI did. It comes from what Anthropic did to themselves.</p><p>Back on January 9, 2026 — weeks before any of the viral drama — Anthropic quietly flipped a switch: <strong>OAuth tokens from Claude subscriptions were banned in all third-party tools</strong>. OpenClaw, OpenCode, Cline, even Anthropic’s own Agent SDK. No announcement. No documentation until February 17–18, over a month later.</p><p>The developer backlash was brutal:</p><blockquote><em>“Anthropic has the best model for agentic work, and they’re actively discouraging people from using it for agentic work.”</em></blockquote><p>That quote popped up everywhere. Reddit threads, HN front page, GitHub issues — devs were furious. People started writing migration guides with titles like <em>“How to Switch OpenClaw from Claude to ChatGPT (And Why Everyone Is)”</em>. Someone filed a GitHub issue to swap OpenClaw’s default model from Claude Opus 4.6 to Gemini 3.1 Pro.</p><p>And this is where the conspiracy theory gets really elegant, because Anthropic’s move was <strong>completely predictable</strong>. Do the math: a $200/month Max subscription running agentic Opus workloads would cost $1,000+ if billed through the API. That business model was bleeding money. Anyone with a calculator could see the crackdown coming.</p><p>So if you were running a long game, here’s how you’d play it: first, build your tool on Claude so users fall in love with the quality. Then wait for Anthropic to inevitably protect their margins by cutting off third-party access. Users get kicked off Claude and need a new model — guess who’s waiting with open arms? And finally, your guy joins OpenAI, and the whole project pivots to become an OpenAI-first platform.</p><p>Anthropic ended up playing the villain in a story they didn’t even know they were cast in.</p><h3>Three Names, One Trajectory</h3><p>Watch how the name evolved:</p><ol><li><strong>Clawdbot</strong> (Nov 2025) → Wears Claude’s colors. Anthropic-adjacent.</li><li><strong>Moltbot</strong> (Jan 27) → Forced rebrand after the C&amp;D. “Lobster molting” — shedding old skin.</li><li><strong>OpenClaw</strong> (Jan 30) → Final form. Look at that prefix.</li></ol><p><strong>“Open</strong>Claw.” Not ClaudeClaw. Not AnthropicClaw. In the AI world of 2026, slapping “Open” on your project name sends a very specific signal — community-driven, model-agnostic, nobody’s property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2J6AVs-yGqcNAWpK.png" /></figure><p>There’s a darker irony though. “Open” also happens to be the first word in <strong>OpenAI</strong> — a company that, despite the name, is probably the least open of the major labs. Steinberger may not have planned this, but by the time Sam Altman tweeted that OpenClaw would become “core to our product offerings,” the name didn’t sound like an independent open-source project anymore. It sounded like an OpenAI sub-brand that had always been waiting to come home.</p><h3>Follow the Winners</h3><p>Forget motive for a second. Just look at who walked away better off.</p><p><strong>OpenAI</strong> went from losing the developer wars to acquiring a 180K-star project, a top agent developer, and a narrative that Anthropic was the enemy of open source. <strong>Steinberger</strong> went from an indie dev burning $10K/month to an OpenAI employee who turned down nine figures from Meta. <strong>Schlicht</strong> went from running a mid-tier VC fund to owning the most-discussed AI social experiment of 2026.</p><p>And <strong>Anthropic</strong>? They went from dominating developer tools and growing revenue to getting branded “anti-open-source,” losing users to OpenAI models, and watching their own Claude ecosystem fracture.</p><p>Every single player in this story came out ahead — except the one company that was winning before OpenClaw existed. When every outcome in a game converges against a single player, you start to wonder if somebody stacked the deck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qf5D90JCZJ5lLMW2.png" /></figure><h3>The Counter-Arguments</h3><p>I’d be a bad analyst if I didn’t try to tear my own theory apart. So let’s do that.</p><p><strong>“Steinberger is Austrian. He’s not Silicon Valley.”</strong><br>True. But the internet doesn’t require geographic proximity for network effects, and Steinberger eventually flew to SF for meetings. The YC network is one phone call away from anyone building in AI right now.</p><p><strong>“The project was genuinely named after Claude because Steinberger admired it.”</strong><br>Plausible. Many open-source projects are named after their inspirations. But this makes the speed of the OpenAI pivot even more suspicious — going from Claude superfan to OpenAI employee in 90 days is a narrative arc that strains credulity.</p><p><strong>“OpenAI’s hiring process can move fast for exceptional talent.”</strong><br>They can. But “fast” in Big Tech usually means 3–4 weeks, not “announce your viral project, fly to SF, and have Sam Altman tweet about you” in 15 days.</p><p><strong>“Correlation isn’t causation.”</strong><br>This is the strongest counter-argument, and I have to concede it. Everything presented here is circumstantial. There’s no leaked email, no anonymous source, no paper trail connecting OpenAI to OpenClaw before the acqui-hire. The timeline is suspicious, the network connections are real, but the <strong>smoking gun doesn’t exist</strong>.</p><h3>The Conspiracy Probability Matrix</h3><p>After spending far too many hours on this, here’s where I land:</p><p><strong>Scenario A: Pure coincidence (30%)</strong><br>Everything happened organically. Steinberger built a cool thing, it went viral through genuine community enthusiasm, and OpenAI opportunistically hired him. Schlicht launched Moltbook independently. Anthropic’s C&amp;D was standard trademark enforcement. The timeline is suspicious but ultimately just a fast-moving industry being fast.</p><p><strong>Scenario B: Somebody gave it a push (45%)</strong><br>OpenAI didn’t build OpenClaw from scratch. But someone in the YC orbit — maybe through Schlicht, maybe through connections we don’t know about — spotted Steinberger’s project early and nudged things along at critical moments. Moltbook’s launch date wasn’t random. OpenAI had already been talking to Steinberger before any of the viral stuff happened, and the acqui-hire was basically agreed to in principle, just waiting for the numbers to prove the hype.</p><p><strong>Scenario C: The whole thing was a play (25%)</strong><br>OpenAI bankrolled or encouraged OpenClaw from the start, using the YC network as a buffer to keep their name clean. The Claude branding was intentional misdirection. Schlicht built Moltbook as a launch vehicle. The C&amp;D, the viral wave, the acqui-hire — all choreographed to hurt Anthropic and hand OpenAI a developer community on a silver platter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sWTFeHzHOpRungQi.png" /></figure><p>I think we’re somewhere between A and B. Scenario C needs too many people keeping secrets in an industry that leaks like a sieve. But Scenario A asks you to believe in a miraculous run of luck that just happens to benefit one company over all others.</p><p>The answer that keeps nagging at me is honestly the most uncomfortable one: <strong>maybe it’s not a conspiracy at all, but a system</strong>. The YC network, the VC money, the gravity well of OpenAI’s brand and resources — these things create a world where projects like OpenClaw drift toward OpenAI on their own. Nobody needs to pull strings when the strings are already attached.</p><p>You don’t need a conspiracy when you have a network.</p><p>Then again — that’s exactly what they’d want you to think.</p><p><em>Full disclosure: everything in this article is speculation built on publicly available information. I have no leaked emails, no insider sources, no smoking gun. The timelines, dollar figures, and quotes all come from published reporting. Read this as analysis and commentary — not as established fact. If any party named here wants to set the record straight, my DMs are open.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f10163ec29f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Steps Password Hashing, Don’t Let Basic Features Turn into Nightmares: Building a Security System…]]></title>
            <link>https://scale-aisystemarchitect.medium.com/5-steps-password-hashing-dont-let-basic-features-turn-into-nightmares-building-a-security-system-cf636bd613d4?source=rss-46df7aa4665b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf636bd613d4</guid>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[systems-thinking]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Nguyễn Anh Bình]]></dc:creator>
            <pubDate>Tue, 01 Oct 2024 18:18:27 GMT</pubDate>
            <atom:updated>2024-10-01T18:27:20.574Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Steps Password Hashing, Don’t Let Basic Features Turn into Nightmares: Building a Security System from a System Architect’s Perspective</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULlUyKz3rIEwzQEXkxxy6g.png" /></figure><p><strong>Meta Fined $102 Million for Storing Passwords in Plain Text. I bet you don’t secure your users’ passwords well enough, even within your developer team.</strong></p><p><em>Original blog in </em><a href="https://www.omelet.tech/password-security-lessons-from-meta/"><em>Vietnamese</em></a></p><h3>Read the news</h3><p><strong>Meta Fined $102 Million for Storing Passwords in Plain Text</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XU82A8dcxuT42EAp.png" /></figure><p>The Irish Data Protection Commission (DPC) imposed a $101.5 million (91 million euros) fine on Meta following the conclusion of an investigation into a 2019 security breach. In this incident, Meta inadvertently stored user passwords in plain text, making them easily readable on the company’s servers.</p><p>Initially, Meta announced that a number of user passwords had been discovered stored in plain text in January 2019. However, a month later, the company revealed that millions of Instagram passwords were also affected. Although Meta did not disclose the exact number of compromised accounts, a senior employee revealed to <em>Krebs on Security</em> that up to 600 million passwords had been stored in plain text. Some of these passwords dated back to 2012, and over 20,000 Facebook employees could access them. However, the DPC clarified that no external parties were granted access.</p><p><strong>Summary</strong><br>If you store passwords as plain text for your employees or development team to access, you’ll face penalties from data protection authorities.</p><h3>Learn from it</h3><p>On This Occasion, Why Don’t We Review Some Knowledge About Software Engineering Principles?</p><h4><strong>Password Storage Best Practices</strong></h4><p>To protect user information and maintain their trust, securely storing passwords is crucial. Here are some best practices for password storage that every organization should implement:</p><figure><img alt="Password handling proposal" src="https://cdn-images-1.medium.com/max/533/1*W84wuRPLrbT6RI94IRk_NQ.gif" /><figcaption>Password hashing process proposal</figcaption></figure><p><strong>1. Hash All Passwords</strong><br>Never store passwords in plain text. Instead, create a hash value from the password and store that hash. Hashing protects the password because it cannot be reversed back to the original password.</p><p>Example:</p><pre>import hashlib<br><br>password = &quot;mysecretpassword&quot;<br>hashed_password = hashlib.sha256(password.encode()).hexdigest()<br>print(hashed_password)</pre><p><strong>2. Use Strong Hashing Functions</strong></p><p>Not all hashing functions are secure. Use hashing functions like Argon2, bcrypt, or scrypt, as recommended by OWASP, since they are designed to resist brute-force attacks.</p><p>Example:</p><pre>import bcrypt<br><br>password = &quot;mysecretpassword&quot;<br>hashed_password = bcrypt.hashpw(password.encode(), bcrypt.gensalt())<br>print(hashed_password)</pre><p><strong>3. Add a Pepper</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_CDQ0CYAp4bqyifO.png" /><figcaption>Secret Manager service</figcaption></figure><p>Pepper is a random string applied to all passwords but is not stored alongside the password database. It’s usually stored in a secure place, and I recommend using secret manager services for this.</p><p>Example:</p><pre>import bcrypt<br>from google.cloud import secretmanager<br><br>client = secretmanager.SecretManagerServiceClient()<br><br>project_id = &quot;your-gcp-project-id&quot;<br>secret_id = &quot;your-secret-id&quot;<br>version_id = &quot;latest&quot;<br><br>name = f&quot;projects/{project_id}/secrets/{secret_id}/versions/{version_id}&quot;<br>response = client.access_secret_version(name=name)<br><br>pepper = response.payload.data.decode(&quot;UTF-8&quot;)<br><br>password = &quot;mysecretpassword&quot;<br>password_pepper = password + pepper<br><br>salt = bcrypt.gensalt()<br>hashed_password = bcrypt.hashpw(password_pepper.encode(), salt)<br><br>print(hashed_password)</pre><p><strong>4. Add Salt to Passwords</strong><br>Salt is a random string added to the password before hashing. This ensures that identical passwords will have different hash values, preventing attackers from using rainbow tables to crack passwords.</p><p>Example:</p><pre>import bcrypt<br><br>password = &quot;mysecretpassword&quot;<br>salt = bcrypt.gensalt()<br>hashed_password = bcrypt.hashpw(password.encode(), salt)<br><br>print(&quot;Salt:&quot;, salt)<br>print(&quot;Salted and hashed password:&quot;, hashed_password)</pre><p><strong>5. Update Work Factors Regularly</strong><br>Hashing functions often have parameters to adjust the difficulty of the hashing process. These factors should be updated periodically to ensure password hashing remains difficult as technology improves.</p><p>Example:</p><pre>import bcrypt<br><br>password = &quot;mysecretpassword&quot;<br>work_factor = 12<br>hashed_password = bcrypt.hashpw(password.encode(), bcrypt.gensalt(work_factor))<br>print(hashed_password)</pre><h4>But is That Enough?</h4><p>I don’t think the issue is just about the technical storage of passwords. Even the least experienced developers know that storing passwords as plain text is a bad idea. And Mark Zuckerberg isn’t hiring amateurs from Harvard to read our messages.</p><p>I suspect this wasn’t an intentional design decision. More likely, the passwords were either accidentally or deliberately logged in files or other locations. I’ve looked into this idea further.</p><p>Here’s what I found: A senior Facebook employee revealed more details to <em>KrebsOnSecurity</em>, saying:</p><blockquote><em>“Facebook is probing a series of security failures in which employees built applications that logged unencrypted password data for Facebook users and stored it in plain text on internal company servers.”</em></blockquote><p>This indicates the problem may be more serious than we thought. Rather than just a simple oversight, it appears that applications were intentionally designed to collect and store passwords insecurely. This is a major violation of security processes and user privacy.</p><h4><strong>What’s the Solution?</strong></h4><p><strong>Code Review Is Not Enough</strong><br>Let’s think about how to prevent the systems we are building, or will build in the future, from encountering similar issues. It’s easy to say “review code thoroughly,” but this is no magic wand that solves all problems.</p><p>Thorough code review is time-consuming and often ends with a superficial “looks fine” from a lead engineer glancing at a function name without fully understanding its content. Will a write_error_log line in some library that logs all fields when an error occurs be caught in a review? And what happens when the library is updated?</p><h4><strong>System Design Solutions</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Wu6nR9GPCofvtL3nZkf3IA.gif" /><figcaption><strong>Services Design Proposal</strong></figcaption></figure><p>A more effective approach to enhancing security and ensuring consistent password handling is to implement all password-related processes as middleware at the API gateway. This approach has several important benefits:</p><ul><li><strong>Centralization</strong>: Passwords are handled directly at the layer closest to the user, minimizing the number of code segments with access to user passwords, and reducing the risk of leaks through logs. This centralization also limits the development team size, reducing human-factor security risks (the more people involved, the greater the risk of security holes).</li><li><strong>Consistency</strong>: Ensures that all requests are handled according to the same security standard.</li><li><strong>Simplification of Backend Services</strong>: Other microservices don’t need to worry about handling passwords. Instead, the User ID is attached directly to the request context, allowing the destination service to identify the user making the request.</li></ul><h4><strong>Conclusion</strong></h4><p>It’s unclear what went wrong at Meta, but it seems they (the most smart guys in the world) did something wrong.</p><p>Through this post, I hope to help those starting to build new systems understand the standards needed to avoid paying the price for something as basic as password storage.</p><p>Once again, <em>Software Engineering Principles</em> remain important, though sometimes we forget them. Maybe it’s time to revisit that book sitting on the school library shelf that you once ignored?</p><figure><img alt="Tangled Web A Guide to Securing Modern Web Applications" src="https://cdn-images-1.medium.com/max/1024/0*3181Y6QckSQ7Fann.png" /></figure><h4><strong>Reference:</strong></h4><ul><li><a href="https://snyk.io/learn/password-storage-best-practices/?ref=omelet.tech">Password Storage Best Practices</a></li><li><a href="https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html?ref=omelet.tech">OWASP Password Storage Cheat Sheet</a></li><li><a href="https://krebsonsecurity.com/2019/03/facebook-stored-hundreds-of-millions-of-user-passwords-in-plain-text-for-years/?ref=omelet.tech">Facebook Stored Hundreds of Millions of User Passwords in Plain Text for Years</a></li><li><a href="https://www.omelet.tech/password-security-lessons-from-meta/">Vietnamese Blog</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf636bd613d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Benefits of Encapsulating the Logging Module in a Custom Class for Large-Scale Projects]]></title>
            <link>https://scale-aisystemarchitect.medium.com/the-benefits-of-encapsulating-the-logging-module-in-a-custom-class-for-large-scale-projects-3434ec18a01f?source=rss-46df7aa4665b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3434ec18a01f</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Nguyễn Anh Bình]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 06:11:56 GMT</pubDate>
            <atom:updated>2022-12-29T06:31:58.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YA9daS3xK0WjsjDPAl6zng.png" /><figcaption>source: <a href="https://www.toptal.com/python/in-depth-python-logging">https://www.toptal.com/python/in-depth-python-logging</a></figcaption></figure><h3>Introduction</h3><p>Object-oriented programming (OOP) is a programming paradigm that is based on the concept of “objects”, which can contain data and code that manipulates that data. In Python, a class is a blueprint for creating objects. It defines the attributes (properties) and behaviors (methods) that the objects of the class will have.</p><p>Writing the logging module as a class has several benefits:</p><ol><li>Encapsulation: By encapsulating the logging functionality within a class, you can hide the implementation details from the rest of the program, allowing you to change the implementation without affecting the rest of the program.</li><li>Reusability: If you write the logging module as a class, you can easily reuse it in other projects by simply creating an instance of the class and calling its methods. This is more efficient than copying and pasting code from one project to another.</li><li>Extension: If you need to add additional functionality to the logging module, you can do so by creating a subclass of the original logging class and adding the new methods and attributes to the subclass.</li><li>Modularity: By writing the logging module as a class, you can separate the logging functionality from the rest of the program, which can make the program easier to understand and maintain.</li></ol><p>This blog describe why should we write logger as class</p><h3>What we’re handle in logging module</h3><h3>There are several common attributes that you might use in the logging module:</h3><ol><li>Message code: A message code is a short, unique identifier for a log message. You can use message codes to quickly identify specific log messages in a large log file.</li><li>Message ID: A message ID is a unique identifier for a log message that is generated automatically by the logging module. You can use message IDs to track log messages over time and across different systems.</li><li>Logging callbacks: A logging callback is a function that is called whenever a log message is emitted. You can use logging callbacks to perform additional processing on log messages, such as sending an email or storing the log message in a database.</li><li>Handlers: Handlers are responsible for routing log messages to the appropriate destination. The logging module provides several built-in handlers, such as StreamHandler (for logging to the console), FileHandler (for logging to a file), and SMTPHandler (for logging to an email server). You can use these handlers to customize where log messages are sent.</li></ol><h3>Use cases:</h3><ol><li>Multi-language logging: If your application supports multiple languages, you may want to log messages in different languages depending on the user’s preferred language. You can use the logging module’s internationalization features to support multi-language logging.</li><li>Changing the logging end-point: You might want to change the logging end-point if you want to send log messages to a different destination. For example, you might want to change the logging end-point from a local file to a cloud storage service like Amazon S3 or Google Cloud Storage. You can do this by changing the logging handler to a handler that is capable of sending log messages to the desired end-point.</li><li>Changing the logging message: You might want to change the logging message if you want to modify the content of the message or the way it is formatted. For example, you might want to add additional information to the message, or change the message template to use a different formatting style. You can do this by modifying the message template or the <strong>msg</strong> attribute of the <strong>LogRecord</strong> class.</li><li>Changing the logging ID: You might want to change the logging ID if you want to track log messages using a different identifier. For example, you might want to change the logging ID from a simple sequential number to a more complex identifier that includes additional information about the log message. You can do this by modifying the <strong>msg</strong> attribute of the <strong>LogRecord</strong> class or the <strong>message_id</strong> attribute of the <strong>Logger</strong> class.</li></ol><h3>How to do</h3><h4>Logging module as we know</h4><pre>impoprt logging<br>logger = logging.getLogger(__name__)<br>def do_something():<br>    logger.debug(&quot;Doing something&quot;)<br>    try:<br>        # Do something that might fail<br>    except Exception as e:<br>        logger.exception(&quot;An error occurred while doing something&quot;)</pre><h4>In Scale project, we should do:</h4><p>Create a file called log_message_define.py. This file controls the message code, content, and level of messages in the logging module.</p><pre>from logging import ERROR, DEBUG, INFO<br>D_COMN_01 = (&quot;D_COMN_01&quot;, &quot;Process &#39;{process_name}&#39; elapsed: {elapsed_time}s&quot;, DEBUG)<br>D_COMN_02 = (&quot;D_COMN_02&quot;, &quot;&#39;{result}&#39; = {value} is not a valid result&quot;, ERROR)<br>D_COMN_03 = (&quot;D_COMN_03&quot;, &quot;&#39;{name}&#39; has shape of {shape}&quot;, INFO)</pre><p>Write logger as a class:</p><pre>class ZLogger(logging.Logger):<br>    def __init__(self, name: str = &quot;Zlogger&quot;, level: int = logging.NOTSET):<br>        super().__init__(name, level)<br><br>        self.addHandler(logging.StreamHandler())<br>        # Add cloud logging handler<br>        self.__add_cloud_logging_handler()<br><br>        # Add AWS logging handler<br>        self.__add_aws_logging_handler()<br><br>    def log_elapsed_time(self, process_name: str, elapsed_time: float):<br>        &quot;&quot;&quot;<br>        Log elapsed time for a process.<br>        Args:<br>            process_name(str): Name of the process<br>            elapsed_time(float): Elapsed time in seconds<br>        &quot;&quot;&quot;<br>        self.__do_log(*D_COMN_01, process_name=process_name, elapsed_time=elapsed_time)<br><br>    def __do_log(self, code: str, template: str, level: int, **kwargs):<br>        message = template.format(**kwargs)<br>        full_message = f&quot;{code}: {message}&quot;<br>        self.log(level, full_message)</pre><h3>Benefits of Writing the Logging Module as a Class</h3><p>Encapsulating the logging functionality in a custom logger class can help you create a more organized, efficient, and maintainable logging system for your application. By providing specific methods for logging common messages, you can enforce a consistent style and structure for log messages, which can make it easier to read and interpret log messages. You can also add docstrings to the methods in the custom logger class to provide clear documentation for how to use the logging functionality.</p><p>Using a custom logger class can also improve the separation of concerns between the application layer and the platform layer in your application. The application layer developers can focus on the business logic of the application, and they can use the custom logger class to log messages at the appropriate level of severity. The platform layer developers can then focus on how the log messages are displayed, routed, and stored, without having to worry about the specifics of the application logic.</p><p>Here is an example of how you might use a custom logger class in your application:</p><p>Example case: project need to add log elapsed time of a function.</p><p>Sample 1: Direct python logging module</p><pre>import logging<br><br>from src.logger.log_message_define import D_COMN_01<br><br>logger = logging.getLogger(__name__)<br>logger.addHandler(logging.StreamHandler())<br><br>def do_logic_1():<br>    # do the logic<br><br>    # start logging<br>    code, message_template, level = D_COMN_01<br>    message_template.format(process_name=&quot;process1&quot;, elapsed_time=123.45)<br>    message = f&quot;{code}: {message_template}&quot;<br>    logger.log(level, f&quot;{code}:{message}&quot;)</pre><p>Sample 2: Using custom Logger class</p><pre>from src.logger.log_message_define import D_COMN_01<br>from src.logger.z_logger import ZLogger<br><br>z_logger = ZLogger()<br><br><br>def do_logic_1():<br>    # do the logic<br><br>    # start logging<br>    z_logger.log_elapsed_time(&quot;process1&quot;, 123.45)</pre><h3>Compare</h3><p>Here is a comparison of the benefits and drawbacks of using a custom logger class like <strong>ZLogger</strong> (Sample 2) versus using the basic <strong>logging.Loger</strong> class (Sample 1) for logging in your application:</p><p><strong>Benefits of Sample 2 (custom logger class):</strong></p><ul><li>Maintainability: Encapsulating the logging functionality in a separate class allows you to hide the implementation details from the rest of the program, making it easier to change the logging module without affecting the rest of the application.</li><li>Documentation: Adding docstrings to the methods in the custom logger class provides clear documentation for how to use the logging functionality, helping other developers understand how to use the logging module and avoid common mistakes.</li><li>Control: Providing specific methods for logging common messages enforces a consistent style and structure for log messages, making them easier to read and interpret, and helping you quickly identify specific log messages in a large log file.</li><li>Reusability: Encapsulating the logging functionality in a separate class allows you to reuse the same logging code in multiple places throughout your application, helping you avoid duplicating code and making it easier to maintain the logging system as your application evolves.</li></ul><p><strong>Drawbacks of Sample 1 (basic logger class):</strong></p><ul><li>Maintainability: Not encapsulating the logging functionality in a separate class exposes the implementation details to the rest of the program, making it harder to change the logging module without affecting the rest of the application.</li><li>Documentation: Not providing any documentation for how to use the logging functionality makes it harder for other developers to understand how to use the logging module and avoid common mistakes.</li><li>Control: Not enforcing a consistent style and structure for log messages makes it harder to read and interpret log messages, and also makes it more difficult to quickly identify specific log messages in a large log file.</li><li>Reusability: Not encapsulating the logging functionality in a separate class prevents you from reusing the same logging code in multiple places throughout your application, leading to duplicated code and making it harder to maintain the logging system as your application evolves.</li></ul><p>I hope this comparison helps you understand the benefits and drawbacks of using a custom logger class like <strong>ZLogger</strong> versus using the basic <strong>logging.Loger</strong> class for logging in your application.</p><p>In summary, using a custom logger class like <strong>ZLogger</strong> provides a more organized, efficient, and maintainable approach to logging, as it allows you to centralize the logging functionality in one place, enforce a consistent style and structure for log messages, and reuse the same logging code throughout your application. This can help you create a more robust, scalable, and maintainable logging system for your application.</p><p>On the other hand, using the basic <strong>logging.Loger</strong> class does not provide the same level of organization, efficiency, and maintainability as using a custom logger class. It exposes the implementation details to the rest of the program, does not provide any documentation for how to use the logging functionality, does not enforce a consistent style and structure for log messages, and does not allow you to reuse the same logging code throughout your application.</p><p>Overall, it is generally a good idea to use a custom logger class like <strong>ZLogger</strong> in your application to improve the organization, efficiency, and maintainability of your logging system.</p><h3>Conclusion</h3><p>It is generally easier to use the basic logging module directly when working on a small application. However, as your application grows in size or the number of developers working on it increases, it may be more beneficial to use a custom logger class like ZLogger to manage your logging system. This is because a custom logger class can provide additional benefits such as better maintainability, documentation, control, and reusability, which can help you create a more robust, scalable, and maintainable logging system. The decision to use a custom logger class or the basic logging module will depend on the specific needs and goals of your application. If you are working on a small application that does not require advanced logging functionality, the basic logging module may be sufficient. However, if you are working on a larger application or have specific requirements for your logging system, using a custom logger class like ZLogger may be a better choice.</p><p>Resource</p><p>Github for sample code:</p><p><a href="https://github.com/maycuatroi/logger-as-a-class-template">maycuatroi/logger-as-a-class-template</a></p><p>Reference:</p><ol><li>The official Python documentation on OOP: <a href="https://docs.python.org/3/tutorial/classes.html">https://docs.python.org/3/tutorial/classes.html</a>. This is a comprehensive guide to OOP in Python, including information on class definitions, inheritance, method resolution order, and more.</li><li>The Python OOP tutorial by Corey Schafer: <a href="https://www.youtube.com/watch?v=ZDa-Z5JzLYM">https://www.youtube.com/watch?v=ZDa-Z5JzLYM</a>. This is a comprehensive tutorial on OOP in Python, with examples and explanations of how to define classes, create objects, and use inheritance.</li><li>The official Python documentation on the logging module: <a href="https://docs.python.org/3/library/logging.html">https://docs.python.org/3/library/logging.html</a>. This is a comprehensive guide to the logging module, including information on how to use it, configure it, and extend it.</li><li>The logging HOWTO in the Python documentation: <a href="https://docs.python.org/3/howto/logging.html">https://docs.python.org/3/howto/logging.html</a>. This HOWTO provides a tutorial on how to use the logging module, with examples of common tasks and scenarios.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3434ec18a01f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>