惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

IT之家
IT之家
U
Unit 42
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
G
Google Developers Blog
Recent Announcements
Recent Announcements
B
Blog RSS Feed
罗磊的独立博客
博客园 - Franky
J
Java Code Geeks
S
SegmentFault 最新的问题
D
DataBreaches.Net
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
腾讯CDC
博客园_首页
美团技术团队
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏

Homepage on Aditya Telange

One Year with evil-winrm-py - A Retrospective Bypassing LinkedIn's Connection Privacy with a Simple Search Filter Making Dynamic Instrumentation Accessible with Frida UI Breaking Payload Encryption in Web Applications HackTheBox (HTB) - Escape HackTheBox (HTB) - Resolute HackTheBox (HTB) - Certified State of VMWare Workstation (Pro?) on Linux Android App Security Testing Lab with MobSleuth Android phone as a Webcam on Linux Breaking down Reverse shell commands HackTheBox (HTB) - Photobomb Primer on HTTP Security Headers Image Zoom-In effect with HUGO HackTheBox (HTB) - Legacy HackTheBox (HTB) - Lame Cryptohack - Keyed Permutations [5 pts] Cryptohack - Resisting Bruteforce [10 pts] Cryptohack - RSA Starter 1 [10 pts] Cryptohack - Base64 [10 pts] Cryptohack - Bytes and Big Integers [10 pts] Cryptohack - Hex [5 pts] Cryptohack- XOR Starter [10 pts] HackTheBox (HTB) - Horizontall HackTheBox (HTB) - Forge HackTheBox (HTB) - Previse HackTheBox (HTB) - BountyHunter HackTheBox (HTB) - Explore HackTheBox (HTB) - Cap HackTheBox (HTB) - Pit
Merging AOSP Security Patches into Custom ROMs
[Aditya Telange](https://x.com/adityatelange) · 2023-01-28 · via Homepage on Aditya Telange

Introduction

Google publishes Android Security Bulletin (ASB) on the first Monday of each month where they list details of security vulnerabilities affecting Android devices. 1

This bulletin mentions a Security patch level YYYY-MM-01 or YYYY-MM-05. These are the dates on which the patches are tagged 2! Read more on How Monthly Android Security Patch Updates Work by XDA.

Android Security patch level is mentioned in the Settings -> About Phone section.

Now, AOSP has a ton of repositories 3 that get downloaded when we do repo sync 4. These projects are present inside the manifest. You can browse them all here https://github.com/orgs/aosp-mirror/repositories.

After the platform fixes(patches) are merged into AOSP, these security-related patches are tagged with the prefix android-security-12.0.0_rXY (with X and Y being the versioning in incrementing order).

Example: Tag android-security-12.0.0_r43 on repo platform_build. https://github.com/aosp-mirror/platform_build/releases/tag/android-security-12.0.0_r43

Most of the custom roms projects maintain a forked version of these repositories to customize them. These security patches are then pulled into their respective forks. After all the security patches are merged, the Security String is updated to the corresponding Security patch level mentioned in ASB.

The security patch level is present in platform/build/core/version_defaults.mk inside a variable PLATFORM_SECURITY_PATCH.

Take a look at this commit history for LineageOS: Update Security String to YYYY-MM-DD

Manual way of merging security patches

So now that we know how the whole things work, we now have to get these security patches merged from AOSP into our own (forked) source.

Assuming you know how to sync sources, we first sync the clean AOSP source as it is using Downloading the Source | Android Open Source Project.

Then perform the following setups to get security patches from android-security-12.0.0_r43 and the version we are currently patched with android-security-12.0.0_r42:

  1. We sync last month’s AOSP tag or tag on which we have already patched previously.

    • Suppose we want to merge android-security-12.0.0_r43 released in January 2023,
    • We sync android-security-12.0.0_r42.
    • repo init -u https://android.googlesource.com/platform/manifest \
        -b android-security-12.0.0_r42 --depth=1
      
    • repo sync --force-sync --current-branch --no-clone-bundle \
        --optimized-fetch --prune -j$(nproc --all)
      
  2. Fetch the presnt month’s tag/latest tag.

    • We use repo forall
    • repo forall -p -c 'git fetch aosp android-security-12.0.0_r43'
      
  3. Diff the commits/commit hash and save it in a file.

    • repo forall -p -c 'git log --oneline HEAD..FETCH_HEAD' \
        > 12.0.0_r42-to-12.0.0_r43.diff.txt
      
    • The commit hashes will be present in file 12.0.0_r42-to-12.0.0_r43.diff.txt
  4. Cherry-pick these commits into specific repos.

    • For project frameworks/base if we have a fork, we will cherry-pick the above-mentioned commits.
    • If we are dealing with CAF based ROMs such as AOSPA (paranoidandroid) we will clone the repo/project from CAF and then cherry-pick the above mentioned commits from AOSP.
    • As an example, we can see that LineageOS Team has done the same: https://review.lineageos.org/q/topic:S_asb_2023-01
  5. Done! We have added all the security patches to our sources. And ready to ship it with the next release.

✅ We can now add a new commit to android_build/core/version_defaults.mk updating the security patch level string against variable PLATFORM_SECURITY_PATCH and add message as Bump Security String to 2023-01-05.


Credits: