Ivan Christian
    • 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

      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.
      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

    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.
    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
    # SS HW 9? # 1 Consider the following function for string comparison: ``` def compare(string1, string2): if len(string2) != len(string1): return False for i in range(len(string2)): if string2[i] != string1[i]: return False return True ``` In this function, the length of two passwords is compared. Each character of the two passwords is compared and the function returns False when there is a difference. Therefore, a timing attack can be implemented by an adversary by measuring and comparing the computation times of each input. If the adversary gets “False” immediately, it will mean that the length of the user’s input is incorrect. The adversary can proceed to guess the length of the password if the response time is longer/shorter than the previous attempts. Finally, the adversary can guess can first, second, third, or N-th character of the password one by one by comparing the response time, or by brute-forcing the password directly if the length of the password is short. - The problem with this system is that the program gives out too much information to the user through the 1) The program checks for the length of the password, which if failing, would instantly return a False. Using the time taken to return False, the attacker can measure the time taken to check whether it passes the first length conditional or not. If it still returns False but takes slightly longer then the length of the input can be recorded. (Although this might be very hard to do given the simplicity of the program) 2) Once the length is ascertained, the False returned would be coming from the for loop checking the string. Measuring the time taken would be making checks to see whether the element on index i is equal to the password. Example of what is being done: ![](https://i.imgur.com/nhwCTqi.png) Learning the real password can be done by interacting the 2 conditionals in the function. Pseudo code to learning the real password ``` func crack_password(real_passwd): while password not found: initialise length randomise (guessed_passwd) if compare(real_passwd, guessed_passwd) returns False: check time --> If the time is really fast then increase the length and repeat until time taken increases significantly to find the length of the password --> if the length has been ascertained (by checking that the time taken has basically stagnated) then start randomising checking for each element of the string index. If the time taken increases, save the element, craft the password character by character. Repeat until password is found. else: password is found ``` The propsoed fix is to hash the password using SHA-256 to create unique hashes. It is virtually almost undoable with current technology to brute force crack to find the hash, it is also not possible to find the original password since hashing is a one way method since the goal is to learn the original string of the password. Proof-of-concept for the Proposed fix: ``` hash the real password using SHA-256 run the hashed_password through the crack_passwd function func crack_password(real_passwd): while password not found: initialise length randomise (guessed_passwd) if compare(real_passwd, guessed_passwd) returns False: check time --> If the time is really fast then increase the length and repeat until time taken increases significantly to find the length of the password --> if the length has been ascertained (by checking that the time taken has basically stagnated) then start randomising checking for each element of the string index. If the time taken increases, save the element, craft the password character by character. Repeat until password is found. else: password is found This won't work because the ``` Due to the sheer length and number of combinations made by the hashing, it is pretty much impossible to brute force it since it will take at least 3.5 * 10 ^ 63 seconds = 1.1 * 10 ^ 57 years to crack. # 2 Meltdown is a type of side-channel attack that exploits a flaw in modern microprocessors to steal sensitive data such as passwords, encryption keys, and other private information. The main steps an attacker needs to carry out for the Meltdown attack are: 1. Gain access to the victim's system: The attacker needs to gain access to the target system, either physically or remotely, to execute the Meltdown attack. 2. Identify the target data: The attacker needs to identify the specific data that they want to steal, such as passwords, encryption keys, or other sensitive information. 3. Execute the Meltdown attack: The attacker uses the Meltdown exploit to leak the target data from the victim's system. The Meltdown exploit takes advantage of a vulnerability in modern microprocessors, which allows an attacker to access sensitive data from the victim's system memory. 4. Steal the data: Once the data has been leaked, the attacker can steal it and use it for their own purposes. ![](https://i.imgur.com/ymASlD1.png) #### Defense MEchanism ##### Preventing Access to Secret Data. (1) A web browser can execute each web site in a separate process. If spectre is exploited on any web site (say, using Javascript), the attack will not be able to access data from the processes assigned to other web sites. (2) Index masking can replace bounds check to avoid branch jumping. This is not fool proof, as a mask (~ powers of 2) may result in an access outside the required bound. However, it limits the distance of the bounds violation, preventing the attacker from accessing arbitrary memory. (3) Access to pointers could be protected by XOR-ing with a pseudo-random poison value. Not only could the pseudorandom value make it harder for an attacker to find its value, but more significantly, it ensures that mispredictions on the branch instructions used for type checks will result in pointers associated with type being used for another type. These approaches are most useful for JIT compilers, interpreters and other language-based protections, where the runtime environment has control over the executed code and wishes to restrict the data that a program may access. ##### Preventing Data from Entering Covert Channels Potentially, processors could track whether data was fetched as a result of speculative operation. If so, data should be prevented from being used in subsequent operations. However, the effectiveness remains an uncertainty until such processors are developed. At that point in time, depending on the implementation, an attacker could potentially "race" (or adopt another side- or covert-channel) to use the cached data before the prevention mechanism kicks in. ##### Limiting data extraction from covert channels In Javascript, sharedArrayBuffers could be used to create a timing source in conjunction with performance.now(). Resolution of timers (and potentially adding jitters) could make it harder to carry out timing attacks. Also, browsers by default disabled this shared memory and high-resolution timers in light of Spectre attacks. While this approach is easy to roll out as a patch, the errors in data exfiltration (due to a low-resolution timer) could be “smoothened” by averaging, though with a reduction in throughput. So, this approach does not guarantee attacks are not possible. ##### Preventing Branch PoisoningPreventing Branch Poisoning Variant 2 could be mitigated by preventing indirect branch poisoning. Mechanism by Intel & AMD: 1) Indirect Branch Restricted Speculation (IBRS) o Restriction based on code privilege levels. o Prevents indirect branches in privileged code from being affected by branches in less privileged code. 2) Single Thread Indirect Branch Prediction (STIBP) o Restricts branch prediction sharing between software executing on the hyperthreads of the same core. 3) Indirect Branch Predictor Barrier (IBPB) o Prevents software running before setting the barrier (i.e. by flushing the BTB state). These mechanisms require OS/BIOS support for use. Depending on the number and combination of mechanisms used, performance degradation could be factor of 4 of more. ###### Mechanism by Google: 1) Retpoline o Replaces indirect branches with return instructions. o Ensures the return instruction is predicted to a benign endless loop. o The actual target destination is reached by pushing it on the stack (expensive instruction) and returning to it. If return instructions could be predicted by other means, retpoline may be impractical. Hence, Intel issued microcode updates for processors to disable fall-back to BTB for such predictions. ##### Detecting vulnerable endpoints. 1) Spectroscope by Google. o A prototype extension to web browsers to search for endpoints potentially vulnerable to Spectre. o Meant to help security engineers and web developers to track application resources that are not protected from being embedded by other websites (which could then be used for Spectre attack). Spectroscope is meant as a convenience tool, rather than an official security testing product.

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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