-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The method's name describes the method's behavior\n\nConnectWise's ManagedITSync was a Kaseya VSA add-on whose job was to keep ConnectWise PSA's customer-asset inventory in sync with what Kaseya's RMM saw on managed endpoints. New machine discovered by Kaseya, new Configuration record in ConnectWise. The integration ran inside the Kaseya VSA web stack and listened on the same port the MSP's technicians used to reach the management console.\n\nThe integration's HTTP surface is `/KaseyaCwWebService/ManagedIT.asmx`, an ASP.NET SOAP service. Alex Wilson's `owlky.py`, committed to GitHub on November 7, 2017, opens with the URL it points at and the check it uses to confirm a target is exploitable:\n\n```python\nBAD_URI = 'KaseyaCwWebService/ManagedIT.asmx'\n\ndef check_kaseya(hostname, verbose=None):\n for scheme in ('https', 'http'):\n try_url = '{}://{}/{}'.format(scheme, hostname, BAD_URI)\n res = requests.get(try_url, timeout=5)\n\n if 'ManagedIT.asmx?op=' in res.text:\n return try_url\n```\n\nThe check is reachability. `ManagedIT.asmx?op=` is the substring ASP.NET emits in the SOAP service description page. If the page renders, the target is exploitable. There is no auth probe in the script because there is no auth to probe.\n\nThe PoC then issues POSTs to four method endpoints. The transport is unceremonious:\n\n```python\ndef get_kaseya_data(base_url, endpoint, post_data=None, verbose=None):\n endpoint_url = '{}/{}'.format(base_url, endpoint)\n res = requests.post(endpoint_url, data=post_data)\n```\n\nNo cookies, no token, no `SOAPAction` header that the script bothers to set. The integration's four methods that the PoC walks are `ExecuteSQL` (takes a `sql` parameter, runs it), `GetDataSet` (takes a `sql` parameter, runs it, returns the row set), `GetConnectionString` (takes nothing, returns the Kaseya VSA database DSN with credentials), and `GetAllMachineIDs` (returns a base64-gzipped UTF-16 dump of every machine the Kaseya server is currently managing). Each is an internal API call that ConnectWise's integration documented as something Kaseya-internal code would hit, then bound to an unauthenticated HTTP path on the customer's perimeter.\n\n## The RMM was the supply chain\n\nThe point is not the SQL. The point is what `ExecuteSQL` writes to.\n\nKaseya VSA's `administrators` table holds the master-list of accounts that can log into the web console. A Kaseya admin can write an Agent Procedure: a script with full Kaseya VSA syntax that the platform pushes to every endpoint the MSP manages, where it runs as SYSTEM. That capability is what the product is for. An MSP buys Kaseya VSA so that one technician can deploy a Windows patch across two thousand machines in fifteen networks without logging into any of them. The Agent Procedure path is the legitimate workflow.\n\n`owlky.py`'s `reset-support` command writes one row to the `administrators` table and then exits:\n\n```python\nresetuser = 'kaseyasupport'\nresetpass = str(uuid.uuid4()).replace('-','')[-8:]\ncovered = cover_pass_256(resetpass, resetuser)\nresetsql = \"UPDATE administrators SET forceNewPassword=0,disableUntil='1980-01-01 00:00:00.000',\" + \\\n \"adminType=2,adminPassword='cover{}' WHERE adminName='{}'\".format(covered, resetuser)\n\nreset = get_kaseya_data(res_url, 'ExecuteSQL', {'sql': resetsql})\n```\n\n`kaseyasupport` is the account that every Kaseya VSA installs by default for vendor support access. `forceNewPassword=0` disarms the reset-on-login prompt. `disableUntil='1980-01-01'` defeats the lockout policy by predating any plausible disable timestamp. `adminType=2` is full master admin. `adminPassword` is set to the literal string `cover` concatenated with the hex SHA-256 of `(password + username)`, which is Kaseya VSA's storage format. The attacker logs in through the front door with the password the script just printed, and the front door does not see any difference between this admin and the MSP's own.\n\nWhat happens next is Kaseya's documented workflow. The attacker writes one Agent Procedure, schedules it against the \"All Machines\" group, and presses Run. Kaseya VSA pushes the procedure to every endpoint in every customer network the MSP manages. The endpoint runs it as SYSTEM. In MSP hands, this is how Acrobat Reader gets updated. In a GandCrab affiliate's hands, in February 2019, this is how `pewdiepie.exe` reached two thousand endpoints belonging to one MSP's customers.\n\nThis is the canonical [security-tool-as-primitive](/patterns/security-tool-as-primitive) shape. The defender's deploy-everywhere reach is the attacker's deploy-everywhere reach because both are calling the same method on the same agent. The privileged action the RMM ships with is the primitive a ransomware operator wants. The blast radius is the deployment footprint, and the deployment footprint of a Kaseya VSA at an MSP is, by construction, every endpoint that MSP has ever onboarded. Kaseya VSA was the supply chain. ConnectWise hung an unauthenticated SOAP method off it called `ExecuteSQL`.\n\nIt is also the [trust-inversion](/patterns/trust-inversion) shape one floor up. The Kaseya admin login is the authorizer the customer trusts to decide what code runs on which managed endpoint. ConnectWise's integration issues that authorizer to any HTTP caller who can reach `/KaseyaCwWebService/ManagedIT.asmx`. The validation lane (the Kaseya VSA web console's login form) was never the relevant gate, because the trusted lane (the Agent Procedure path executing as SYSTEM on every endpoint) was already running whatever the database said the admin had asked for.\n\n## The patch was a knowledge base article\n\nAlex Wilson reported the bug to ConnectWise during 2017. ConnectWise's response is documented in his own README, which credits the vendor for two specific actions: pulling the integration from the ConnectWise Marketplace, and publishing a knowledge base article in ConnectWise University titled `Kaseya - IP and Domain Restrictions`. The article describes how an MSP can configure their Kaseya VSA's IIS site to restrict which source IPs and domains are permitted to reach `ManagedIT.asmx`.\n\nThere was no code change visible to customers. The integration that was already installed on a customer's Kaseya VSA did not receive an update. No runtime banner warned the MSP that the endpoint was reachable from the internet. No automatic configuration disabled the SOAP service. The customer had to log into ConnectWise University, find the article, understand that it applied to them, log into their Kaseya VSA's IIS Manager, and write the IP rule.\n\nThe integration had often been installed silently as part of a Kaseya VSA setup that bundled the ConnectWise PSA tie-in. Many MSPs did not know they had it. The advisory ConnectWise sent to existing customers was the document explaining that they did.\n\nFor fifteen months, the bug was patched in ConnectWise's mind, in their marketplace listing, and in their knowledge base. It was not patched on any single MSP's Kaseya VSA until that MSP read the article and configured the IP restriction. The customer-side patch rate during that window is the variable that decides whether each individual MSP's two thousand customers got encrypted in February 2019 or did not.\n\n## MITRE caught up the week GandCrab did\n\nThe CVE number `2017-18362` indicates MITRE reserved the identifier in 2017. The record was not published until February 5, 2019.\n\nThe publication date is not a coincidence. The week of February 4, 2019, a GandCrab affiliate ran the chain Alex Wilson had committed to GitHub on November 7, 2017 against publicly-reachable Kaseya VSA servers. Huntress was called in by enough impacted MSPs to recognize the pattern and write up the case. Coveware's incident-response writeup of one Reddit-reported case puts the count at 1,500 to 2,000 endpoints encrypted at a single MSP, with the aggregate ransom demand reportedly over $2.6 million. Huntress published their writeup the same week. MITRE published the CVE record February 5.\n\nThe PoC had been runnable on GitHub for fifteen months. For fifteen months a defender searching the CVE database for Kaseya VSA risks would find nothing about this one; a defender searching GitHub for `ManagedIT.asmx` would find a working exploit script and a README that named the vendor, the endpoint, and the mitigation. The two populations of defender, the ones who watch CVE feeds and the ones who watch GitHub, are not the same population.\n\nThis is the [disclosure-after-exploitation](/patterns/disclosure-after-exploitation) pattern in its base form. The pipeline ran in reverse: vendor knowledge base article, customer non-update, attacker discovery via Reddit-visible compromise, IR firm pattern match, CVE assignment. The defender's first signal from the CVE infrastructure that the bug had ever existed was the ransom note for the encryption of their customer fleet, not the advisory. Kaseya VSA's place in the catalog joins CrushFTP, FortiManager, and Ivanti as products where the CVE arrives to document a breach record that incident responders have already begun to write. CISA eventually added CVE-2017-18362 to the Known Exploited Vulnerabilities catalog. By the time the federal agency had a remediation directive, the Kaseya VSA on-prem product had been end-of-lifed; the directive was to disconnect the product.\n\n## CWE-89 is the wrong label\n\nThe NVD record assigns CWE-89, \"Improper Neutralization of Special Elements used in an SQL Command.\" CWE-89 is SQL injection. SQL injection assumes there is a query the developer intended to be parameterized and an attacker who smuggled syntax into a parameter to hijack the query's grammar.\n\nThere is no parameterized query here. There is a SOAP method named `ExecuteSQL` whose contract is to run whatever string the caller sends as a `sql` parameter. The handler took the parameter and dispatched it to the database. There is no developer intent that the parameter would be sanitized, because the parameter was meant to be the query.\n\nThe same is true of `GetDataSet`, which is `ExecuteSQL` plus row-formatting; `GetConnectionString`, which is a method whose entire purpose is to return database credentials to the caller; and `GetAllMachineIDs`, which dumps the managed-endpoint inventory. None of these are bugs in a parser. They are documented internal API methods that the integration bound to an unauthenticated HTTP path the customer did not know was listening.\n\nCWE-89 was the closest fit in MITRE's vocabulary. It is not the shape of the bug. The shape of the bug is that the integration's authors believed the SOAP endpoint was only reachable from Kaseya-internal code on the same host, and the customer's IIS configuration believed the SOAP endpoint was a normal `/KaseyaCwWebService/*.asmx` resource that should be served to whoever asked for it. The two beliefs never reconciled, and the document that would have reconciled them lived behind a customer login in ConnectWise University.\n\nPoC: [kbni/owlky](https://github.com/kbni/owlky)","closing_line":"The patch removed a marketplace listing. The endpoint kept listening.","hook_md":"`ManagedIT.asmx` is the SOAP endpoint ConnectWise's ManagedITSync integration installs on Kaseya VSA servers. Open it on a 2017-vintage build and the service description lists its methods. One is named `ExecuteSQL`. Its parameter is `sql`. Its return value is the result. There is no session header, no HTTP Basic, no `` element in the SOAP envelope. The method's name describes the method's behavior, and the method's behavior is the auth model.\n\nCVE-2017-18362 is the fifteen-month window between ConnectWise pulling the integration from their marketplace in November 2017 and MITRE publishing the CVE record on February 5, 2019. The researcher's working exploit script was on GitHub the entire window. ConnectWise's response to the disclosure was a knowledge base article. The customers who logged in and read it kept their fleet. The customers who did not, the week of February 4, 2019, paid GandCrab to decrypt two thousand endpoints.","post_id":595,"slug":"connectwise-cve-2017-18362-executesql-arrived-with-gandcrab","title":"CVE-2017-18362: ConnectWise's ManagedITSync Exposed a SOAP Method Called ExecuteSQL. The CVE Arrived Fifteen Months Later, With GandCrab.","type":"initial","unreadable_sentence":"The method's name describes the method's behavior, and the method's behavior is the auth model."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCaw27ZwAKCRDeZjl4jgkQ JibeAQDekAkY+9RPqN0E4dCipWHRYQNKCWw3HmoFXZmyo6BBiAD+NBxVTisoT4B4 fmDNNR1uf95WRzzERRUkhZSh9IQ84gM= =33tC -----END PGP SIGNATURE-----