{"id":38060724,"url":"https://github.com/bovarysme/memories","last_synced_at":"2026-01-16T20:29:24.553Z","repository":{"id":57554673,"uuid":"118464495","full_name":"bovarysme/memories","owner":"bovarysme","description":"A key-recovery attack for LINE for Android's chat backup encryption.","archived":false,"fork":false,"pushed_at":"2018-06-04T17:26:50.000Z","size":95,"stargazers_count":39,"open_issues_count":0,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-20T11:05:45.741Z","etag":null,"topics":["cryptanalysis","go","golang","key-recovery","line"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bovarysme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-22T14:00:24.000Z","updated_at":"2024-06-17T06:33:12.000Z","dependencies_parsed_at":"2022-09-26T18:51:24.496Z","dependency_job_id":null,"html_url":"https://github.com/bovarysme/memories","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bovarysme/memories","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bovarysme%2Fmemories","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bovarysme%2Fmemories/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bovarysme%2Fmemories/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bovarysme%2Fmemories/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bovarysme","download_url":"https://codeload.github.com/bovarysme/memories/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bovarysme%2Fmemories/sbom","scorecard":{"id":249223,"data":{"date":"2025-08-11","repo":{"name":"github.com/bovarysme/memories","commit":"184639685d709fdc322703d5f20da7096f956cf8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T08:09:07.936Z","repository_id":57554673,"created_at":"2025-08-17T08:09:07.936Z","updated_at":"2025-08-17T08:09:07.936Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptanalysis","go","golang","key-recovery","line"],"created_at":"2026-01-16T20:29:24.476Z","updated_at":"2026-01-16T20:29:24.544Z","avatar_url":"https://github.com/bovarysme.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memories\n\nA key-recovery attack for LINE for Android's chat backup encryption.\n\nLINE for Android has a feature to back up individual chats to a ZIP file. Each\nbackup contains images in plaintext and a weakly encrypted chat database, which\ncan be recovered in fifteen minutes at most on a CPU supporting\n[AES-NI](https://en.wikipedia.org/wiki/AES_instruction_set).\n\n## Usage\n\nBefore anything else, compile the package with `go build` and extract the\nbackup archive (`LINE_Android-backup-chat\u003cid\u003e.zip`). The encrypted chat\ndatabase is the `linebackup/chat/chat\u003cid\u003e` file (and *not* the one with the\n`.extra` extension). Note: `chat\u003cid\u003e` and `chat\u003cid\u003e.extra` need to be in the\nsame directory for the decryption program to work.\n\nDecrypt an encrypted chat database (requires both your MID and your chat\npartner's):\n```\n./memories -source \u003cpath to the encrypted chat db\u003e -oid \u003cyour MID\u003e -tid \u003cyour chat partner's MID\u003e\n```\n\nRecover the key of an encrypted chat database and decrypt it:\n```\n./memories -bruteforce -source \u003cpath to the encrypted chat db\u003e\n```\n\n## Write-up\n### Introduction\n\nEvery LINE user has an internal ID that starts with `u` followed by 32 hex\ndigits (e.g. `u61726520762e206375746520f09f929c`), which is refered to as\n`PROFILE_MID` or `tmId` in the Android app. (This ID is different from the one\nyou can set in the app, and from the `userId` exposed by the LINE Messaging\nAPI.) While it isn't visible to end users, it isn't secret either: I recovered\nmine and my chat partners' using LINE for Google Chrome and Chrome's developer\ntools.\n\nWhen a chat backup is created, both IDs are concatenated and\n[`hashCode()`](https://en.wikipedia.org/wiki/Java_hashCode()#The_java.lang.String_hash_function)ed.\nThe resulting 32-bit integer is then used as an initialization vector (IV) to\nderive a 128-bit encryption key, and the chat database is encrypted using\nAES-ECB with PKCS#5 padding.\n\nAfter finding both IDs and reimplementing the encryption scheme, I was able to\nsuccessfully decrypt a backup made from my account.\n\n### Key-recovery\n\nOn top of the encryption key being derived from a 32-bit integer, the key\nderivation function (KDF) is fast and only called once. This effectively\nreduces the size of the key space to 2^32, which can be searched quickly.\n\nA simple way to search the key space is to derive a key from every possible IV,\nand use it to try to decrypt the first 16-byte block of the ciphertext (which\nis expected to be `SQLite format 3\\x00`).\n\nUsing this attack, I was able to recover a key in less than 4 minutes on a 7\nyears old laptop (i5-2540M @ 2.60GHz).\n\n![Successful key-recovery](docs/hackergirl.png)\n\n### Possible improvements\n\nThe KDF has collisions (e.g. the IVs -1147136985, -1147146969, -1147157209...\nall yield the same key), which leads me to believe this attack could be\nimproved.\n\n### Lessons learned\n\n- Do not use 32-bit IVs.\n- Do not use `hashCode()` as a cryptographic hash function.\n- Do not implement your own KDF.\n- Use a slow KDF to prevent brute-force attacks.\n- [Do not use AES in ECB mode.](https://i.imgur.com/CBdiOQ8.png)\n\n## License\n\nThis project is licensed under the terms of the MIT license, except for the\ncontents of the `crypto` directory which are licensed under the\n[Go BSD-style license](crypto/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbovarysme%2Fmemories","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbovarysme%2Fmemories","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbovarysme%2Fmemories/lists"}