René's URL Explorer Experiment


Title: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) · Issue #1648 · python-kasa/python-kasa · GitHub

Open Graph Title: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) · Issue #1648 · python-kasa/python-kasa

X Title: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) · Issue #1648 · python-kasa/python-kasa

Description: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) Bug Description HS300 (and possibly other IOT devices) with firmware that requires KLAP v2 authentication fail to connect...

Open Graph Description: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) Bug Description HS300 (and possibly other IOT devices) with firmware that require...

X Description: IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) Bug Description HS300 (and possibly other IOT devices) with firmware that require...

Opengraph URL: https://github.com/python-kasa/python-kasa/issues/1648

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2)","articleBody":"# IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2)\n\n## Bug Description\n\nHS300 (and possibly other IOT devices) with firmware that requires KLAP v2 authentication fail to connect with `AuthenticationError: Device response did not match our challenge`. \n\nThe root cause is that `device_factory.py` always uses `KlapTransport` for IOT devices with KLAP encryption, ignoring the `login_version` parameter from discovery. Devices with `login_version=2` require `KlapTransportV2` which uses a different hash algorithm.\n\n## Environment\n\n- python-kasa version: 0.10.2\n- Python version: 3.12\n- OS: Linux (Ubuntu)\n- Device: HS300 Power Strip (hw_ver 2.0)\n\n## Discovery Response\n\nThe device correctly reports `login_version: 2` in discovery:\n\n```python\n{\n    'device_model': 'HS300(US)',\n    'device_type': 'IOT.SMARTPLUGSWITCH',\n    'mgt_encrypt_schm': {\n        'encrypt_type': 'KLAP',\n        'http_port': 80,\n        'lv': 2,  # \u003c-- login_version = 2\n    },\n    ...\n}\n```\n\n## Root Cause\n\nIn `device_factory.py` line 231:\n\n```python\nsupported_device_protocols: dict[str, tuple[type[BaseProtocol], type[BaseTransport]]] = {\n    \"IOT.XOR\": (IotProtocol, XorTransport),\n    \"IOT.KLAP\": (IotProtocol, KlapTransport),  # \u003c-- Always uses KlapTransport (v1)\n    \"SMART.AES\": (SmartProtocol, AesTransport),\n    \"SMART.KLAP\": (SmartProtocol, KlapTransportV2),  # \u003c-- SMART devices use v2\n    ...\n}\n```\n\nThe protocol selection key is built from `device_family + encryption_type` only:\n```python\nprotocol_transport_key = protocol_name + \".\" + ctype.encryption_type.value\n```\n\nThe `login_version` is not considered, so all IOT KLAP devices get `KlapTransport` regardless of their actual requirements.\n\n## Hash Algorithm Difference\n\n- **KlapTransport (v1)**: `MD5(MD5(username) + MD5(password))`\n- **KlapTransportV2 (v2)**: `SHA256(SHA1(username) + SHA1(password))`\n\nWhen the wrong transport is used, the handshake hash comparison fails:\n\n```\nExpected auth_hash (KlapTransportV2): 876584dd4d497651c678a8c3d6cb619c...\nActual _local_auth_hash (KlapTransport): 53a1c1366c1e8e04719da24462371caa\n```\n\n## Steps to Reproduce\n\n```python\nimport asyncio\nfrom kasa import Discover, Credentials\n\nasync def main():\n    creds = Credentials(\"user@example.com\", \"password\")\n    devices = await Discover.discover(\n        target=\"10.0.0.255\",\n        username=creds.username,\n        password=creds.password,\n    )\n    \n    # HS300 with KLAP v2\n    if \"10.0.0.110\" in devices:\n        dev = devices[\"10.0.0.110\"]\n        print(f\"login_version: {dev.config.connection_type.login_version}\")\n        print(f\"Transport: {type(dev.protocol._transport).__name__}\")\n        \n        try:\n            await dev.update()\n        except Exception as e:\n            print(f\"Error: {e}\")\n\nasyncio.run(main())\n```\n\nOutput:\n```\nlogin_version: 2\nTransport: KlapTransport  # \u003c-- Should be KlapTransportV2!\nError: Device response did not match our challenge on ip 10.0.0.110...\n```\n\n## Workaround\n\nManually create `IotProtocol` with `KlapTransportV2`:\n\n```python\nfrom kasa.transports.klaptransport import KlapTransportV2\nfrom kasa.protocols import IotProtocol\nfrom kasa.iot import IotStrip\n\n# Create protocol with correct transport\nprotocol = IotProtocol(transport=KlapTransportV2(config=device_config))\ndevice = IotStrip(host=ip, protocol=protocol)\nawait device.update()  # Works!\n```\n\n## Suggested Fix\n\nModify `get_protocol()` in `device_factory.py` to check `login_version` for IOT KLAP devices:\n\n```python\ndef get_protocol(config: DeviceConfig, *, strict: bool = False) -\u003e BaseProtocol | None:\n    ctype = config.connection_type\n    \n    # ... existing code ...\n    \n    # For IOT devices with KLAP and login_version \u003e= 2, use KlapTransportV2\n    if (ctype.device_family.value.startswith(\"IOT.\") and \n        ctype.encryption_type == DeviceEncryptionType.Klap and\n        ctype.login_version is not None and \n        ctype.login_version \u003e= 2):\n        return IotProtocol(transport=KlapTransportV2(config=config))\n    \n    # ... rest of existing code ...\n```\n\nOr add a new protocol transport key:\n```python\nsupported_device_protocols = {\n    \"IOT.XOR\": (IotProtocol, XorTransport),\n    \"IOT.KLAP\": (IotProtocol, KlapTransport),\n    \"IOT.KLAP.V2\": (IotProtocol, KlapTransportV2),  # \u003c-- New\n    ...\n}\n```\n\n## Additional Context\n\nThis issue appeared after a power outage caused the HS300 devices to reboot. The devices had been updated to newer firmware that uses KLAP v2 authentication. Before the reboot, existing sessions may have been cached, masking the issue.\n\nThe same credentials work correctly in the official Kasa app, confirming the credentials are valid.\n\n---\n\n**Related**: This may affect other IOT devices (not just HS300) that have been updated to firmware requiring KLAP v2.\n","author":{"url":"https://github.com/lasdolphin","@type":"Person","name":"lasdolphin"},"datePublished":"2026-01-23T19:20:29.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1648/python-kasa/issues/1648"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7fee6a93-7467-4188-23e3-73d01cd3e510
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE1EC:75848:25AA2FD:32C085D:6981CA89
html-safe-noncee91a7e2815bb23a30f1b54502a37ba822d0a961937c57e20e0520aa3f4e24582
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUVDOjc1ODQ4OjI1QUEyRkQ6MzJDMDg1RDo2OTgxQ0E4OSIsInZpc2l0b3JfaWQiOiI4MzY2ODgxMTE5NDI5MzE1MjA5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacfaaa844e14baa956ce8d3675f6f761079d97a4a9814b4a0af3c905f9d6010d94
hovercard-subject-tagissue:3848828070
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-kasa/python-kasa/1648/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d765bbd3ab117351249e4824cea17079438fe012f9a9d7406b429d4bd1636bcb/python-kasa/python-kasa/issues/1648
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d765bbd3ab117351249e4824cea17079438fe012f9a9d7406b429d4bd1636bcb/python-kasa/python-kasa/issues/1648
og:image:altIOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2) Bug Description HS300 (and possibly other IOT devices) with firmware that require...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelasdolphin
hostnamegithub.com
expected-hostnamegithub.com
None95dd6eb30a064b87bd2c653e622fe2eb6a2ec1d12751c5463c252220548e75a4
turbo-cache-controlno-preview
go-importgithub.com/python-kasa/python-kasa git https://github.com/python-kasa/python-kasa.git
octolytics-dimension-user_id57733869
octolytics-dimension-user_loginpython-kasa
octolytics-dimension-repository_id221571611
octolytics-dimension-repository_nwopython-kasa/python-kasa
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id221571611
octolytics-dimension-repository_network_root_nwopython-kasa/python-kasa
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7f9fe298cbc605034955dde47054b68dbf531efd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-kasa%2Fpython-kasa%2Fissues%2F1648
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-kasa%2Fpython-kasa%2Fissues%2F1648
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-kasa%2Fpython-kasa
Reloadhttps://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648
Reloadhttps://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648
Reloadhttps://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648
python-kasa https://patch-diff.githubusercontent.com/python-kasa
python-kasahttps://patch-diff.githubusercontent.com/python-kasa/python-kasa
Please reload this pagehttps://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-kasa%2Fpython-kasa
Fork 246 https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-kasa%2Fpython-kasa
Star 1.6k https://patch-diff.githubusercontent.com/login?return_to=%2Fpython-kasa%2Fpython-kasa
Code https://patch-diff.githubusercontent.com/python-kasa/python-kasa
Issues 51 https://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues
Pull requests 36 https://patch-diff.githubusercontent.com/python-kasa/python-kasa/pulls
Discussions https://patch-diff.githubusercontent.com/python-kasa/python-kasa/discussions
Actions https://patch-diff.githubusercontent.com/python-kasa/python-kasa/actions
Projects 0 https://patch-diff.githubusercontent.com/python-kasa/python-kasa/projects
Security 0 https://patch-diff.githubusercontent.com/python-kasa/python-kasa/security
Insights https://patch-diff.githubusercontent.com/python-kasa/python-kasa/pulse
Code https://patch-diff.githubusercontent.com/python-kasa/python-kasa
Issues https://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues
Pull requests https://patch-diff.githubusercontent.com/python-kasa/python-kasa/pulls
Discussions https://patch-diff.githubusercontent.com/python-kasa/python-kasa/discussions
Actions https://patch-diff.githubusercontent.com/python-kasa/python-kasa/actions
Projects https://patch-diff.githubusercontent.com/python-kasa/python-kasa/projects
Security https://patch-diff.githubusercontent.com/python-kasa/python-kasa/security
Insights https://patch-diff.githubusercontent.com/python-kasa/python-kasa/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-kasa/python-kasa/issues/1648
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/python-kasa/python-kasa/issues/1648
IOT devices with KLAP encryption and login_version=2 use wrong transport (KlapTransport instead of KlapTransportV2)https://patch-diff.githubusercontent.com/python-kasa/python-kasa/issues/1648#top
https://github.com/lasdolphin
https://github.com/lasdolphin
lasdolphinhttps://github.com/lasdolphin
on Jan 23, 2026https://github.com/python-kasa/python-kasa/issues/1648#issue-3848828070
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.