<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Loïc Hermann on Medium]]></title>
        <description><![CDATA[Stories by Loïc Hermann on Medium]]></description>
        <link>https://medium.com/@loichrn?source=rss-88975c4e81fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*i2S2HO_lss0pYVKazA_R7g.jpeg</url>
            <title>Stories by Loïc Hermann on Medium</title>
            <link>https://medium.com/@loichrn?source=rss-88975c4e81fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 15:29:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@loichrn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Backup FROM Google Drive (And Why You Need To)]]></title>
            <link>https://medium.com/@loichrn/how-to-backup-from-google-drive-and-why-you-need-to-4e6f26ecc237?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e6f26ecc237</guid>
            <category><![CDATA[data-backup]]></category>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 20:25:26 GMT</pubDate>
            <atom:updated>2026-03-16T20:38:31.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8kDu6NGIcDZ_mx6hduWPOg.png" /></figure><p>You’ve probably been told a thousand times to back up your files to the cloud. Over the years, we’ve all been trained to treat Google Drive, Dropbox, or OneDrive as the ultimate safety net. Drag your important folders in there, and you can sleep soundly knowing your data is safe from a spilled cup of coffee on your laptop.</p><p>Backing up <em>to</em> Google Drive is the easy part. But have you ever stopped to think about backing up <em>from</em> Google Drive?</p><p>Originally published on my blog:<br><a href="https://blog.cloudstic.com/2026/03/04/how-to-backup-from-google-drive/">https://blog.cloudstic.com/2026/03/04/how-to-backup-from-google-drive/</a></p><h3>Sync vs. Backup</h3><p>There is a fundamental misunderstanding about how modern cloud storage works. Most of us use Google Drive as a synchronization engine, not a backup vault.</p><p>Cloud providers are incredibly good at protecting your data from hardware failures. If a hard drive burns out in a Google data center, you won’t even notice. But they are completely powerless against human failure.</p><p>Because file sync is instantaneous, your mistakes are permanent.</p><p>Consider the <strong>“Delete Everywhere” Trap</strong>. When you accidentally delete a folder on your laptop, the Google Drive desktop app doesn’t pause to ask, “Are you sure you want to permanently delete these 500 files?” It just tells the cloud server, “Me too.” If you don’t realize that folder is missing within 30 days (when it gets permanently scrubbed from the trash), it’s not just deleted. It is wiped from the planet.</p><p>Or consider the <strong>Ransomware Threat</strong>. Ransomware doesn’t just lock up your local hard drive. Your cloud provider will faithfully and instantly replace your perfectly healthy cloud documents with the encrypted, unreadable versions created by the malware across every single device linked to your account. Syncing isn’t protection; it’s a high-speed delivery system for data corruption.</p><p>And finally, consider <strong>Account Lockouts</strong>. If your Google account gets suspended, hacked, or locked due to a misunderstood algorithmic flag, you lose your email, your photos, and every single document you ever trusted to the cloud.</p><h3>What Constitutes a Real Backup?</h3><p>A real backup requires <strong>Point-in-Time Snapshots</strong>. You need the ability to tell your system, “Revert my entire cloud drive to exactly how it looked last Tuesday at 10:00 AM.”</p><p>Without immutable snapshots, you are forced to hunt through file-versioning histories document by document, a process that takes hours and almost guarantees you will miss hidden dependencies.</p><h3>How to Back Up Google Drive</h3><p>If you accept that your Google Drive needs to be backed up, how do you actually do it?</p><h3>Option 1: The Manual Route (Google Takeout)</h3><p>Google provides a tool called Google Takeout that lets you export all your data. You can request an archive, wait a few hours (or days) for it to process, download massive ZIP files, and store them on an external hard drive. <strong>The problem:</strong> It requires manual intervention. The moment a backup strategy relies on you remembering to do it every month, it becomes a failed backup strategy.</p><h3>Option 2: Traditional Backup Tools via FUSE Mounts</h3><p>You can use powerful, open-source backup tools like Restic or Borg. To make them work with Google Drive, you mount your cloud drive as a local virtual disk (using tools like rclone FUSE), and then back it up to another location. <strong>The problem:</strong> It&#39;s remarkably slow. According to recent benchmarks, scanning an unchanged Google Drive folder using Borg or Restic over a FUSE mount takes anywhere from 15 to 25 seconds just for 150 files. Scanning hundreds of thousands of files can take hours, creating massive local caching overhead.</p><h3>Option 3: Native Cloud Backups</h3><p>I realized there wasn’t a great answer to this problem, so I started building one named after the very good Restic backup tool. The main difference is that It talks directly to the Google Drive API natively.</p><p>This allow an unprecedented speed. In my benchmarks against an uncached Google Drive repository, Cloudstic can scan the drive and verify a “no-changes” incremental backup in <strong>0.56 seconds</strong>.</p><p>Because it’s built on a modern, content-addressed storage engine, It offers:</p><ul><li><strong>Zero-Knowledge Encryption:</strong> Everything (metadata included) is encrypted with AES-256-GCM using your own keys before it is stored.</li><li><strong>Cross-Source Deduplication:</strong> If you have the same file on your laptop and on Google Drive, Cloudstic recognizes the duplicate data and only stores it once, saving you storage space.</li><li><strong>Instant Restores:</strong> Browse your backup history, compare versions, and restore exactly what you need as a simple ZIP download.</li></ul><h3>A Step-by-Step Guide to Your First Native Drive Backup</h3><p>Getting started with Cloudstic is incredibly simple. You don’t need to mount virtual drives or configure FUSE over macOS recovery mode.</p><p><strong>Step 1: Install the Cloudstic CLI</strong> First, download and install the open-source CLI from our GitHub releases page or via Homebrew:</p><pre>brew install cloudstic/tap/cloudstic</pre><p><strong>Step 2: Initialize Your Encrypted Repository</strong> Choose where you want your backups to live (an AWS S3 bucket, a Backblaze B2 bucket, or even just an external hard drive). For example, to use S3:</p><pre>export CLOUDSTIC_STORE=s3:my-backup-bucket<br>export AWS_ACCESS_KEY_ID=your-key<br>export AWS_SECRET_ACCESS_KEY=your-secret<br><br># This will prompt you to securely enter a strong passphrase<br>cloudstic init -add-recovery-key</pre><p><em>(Make sure to save the recovery key that is generated!)</em></p><p><strong>Step 3: Authenticate with Google</strong> The first time you interact with Google Drive, Cloudstic will seamlessly prompt you to authenticate via your browser and save a secure token.</p><p><strong>Step 4: Run the Backup</strong> Tell Cloudstic to back up your Google Drive natively:</p><pre>cloudstic backup -source gdrive-changes -tag cloud</pre><p>Cloudstic will scan your drive, deduplicate the files against any local backups you’ve already run, encrypt everything with your passphrase, and push it quickly to your storage bucket of choice. Subsequent incremental backups will take just fractions of a second to verify.</p><p><em>(For advanced features like custom retention policies, SFTP storage, or </em><em>.backupignore files, check out the </em><a href="https://docs.cloudstic.com/"><em>official Cloudstic documentation</em></a><em>.)</em></p><h3>A Deep Dive: What’s Actually Happening?</h3><p>If you want to see exactly how Cloudstic achieves this speed, you can run any command with the --debug flag. Here is what happens under the hood when you initialize a repository and back up a Google Drive source (-source gdrive-changes):</p><h3>1. Initialization (cloudstic init)</h3><pre>$ cloudstic init --debug<br>[store #1] GET    config                                              2074.6ms err=NoSuchKey<br>[store #2] LIST   keys/                                                 99.4ms<br>[store #3] PUT    keys/kms-platform-default                            119.8ms 311B<br>[store #4] PUT    config                                               123.6ms 63B<br>Created new encryption key slots.<br>Repository initialized (encrypted: true).</pre><p>Cloudstic first checks if a configuration file already exists (it doesn’t). It then generates a secure master key, encrypts it, and stores it in a key slot.</p><p>If you look closely at line 3 (PUT keys/kms-platform-default) you can notice that In this run, I didn&#39;t just use a password. Cloudstic seamlessly supports <strong>Key Management Systems (KMS)</strong>. Here, the repository&#39;s master key is wrapped by a managed KMS key rather than a user-managed passphrase.</p><h3>2. The First Backup</h3><pre>$ cloudstic backup -source gdrive-changes --debug<br>[store #8] GET    index/snapshots                                      101.0ms err=NoSuchKey<br>[hamt] get node/... hit staging (158 bytes)<br>...<br>Scanning             ... done! [20 in 790ms]<br>[store #14] PUT    chunk/d2667...   807.7ms 1.2MB<br>[store #15] PUT    chunk/3134f...   261.2ms 587.8KB<br>...<br>Uploading            ... done! [45.65MB in 5.995s]<br>[store #51] PUT    packs/d7596...   191.9ms 1.2MB<br>Backup complete. Snapshot: snapshot/6f70aa...</pre><p>When running the first backup, Cloudstic realizes there are no prior snapshots. It scans your Google Drive via the API, chunks the files, encrypts them, and uploads them.</p><p>Notice how it uploads chunks but ultimately writes packs? Cloudstic uses a <strong>packfile architecture</strong>. Instead of uploading 10,000 tiny 1KB files to S3 (which would be agonizingly slow and expensive in API calls), it intelligently bundles them into larger packs (usually around 8MB).</p><h3>3. The Second (Incremental) Backup</h3><p>This is where the magic of native integration happens.</p><pre>$ cloudstic backup -source gdrive-changes --debug<br>[store #8] GET    index/snapshots                                      115.8ms 350B<br>[store #10] GET    packs/d7596...   729.8ms 1.2MB<br>Scanning (increment~ ... done! [0 in 212ms]<br>...<br>Added to the repository: 286 B (315 B compressed)<br>Processed 0 entries in 1s<br>Snapshot 3eb699... saved</pre><p>For the second backup, Cloudstic downloads the index of the previous snapshot. It then asks the Google Drive API for the <em>changes</em> since that snapshot (using delta tokens), rather than walking the entire directory tree again.</p><p>Because nothing changed, the scan takes a mere <strong>212 milliseconds</strong>. It writes a tiny metadata file (the new snapshot pointing to the existing tree root) and exits. Total time: ~1 second.</p><p>No FUSE mounts. No walking thousands of unchanged local directories.</p><h3>Stop Trusting the Sync</h3><p>Syncing to the cloud is just creating a highly efficient mirror for your mistakes.</p><p><em>I hope you liked it! You can check out the open-source backup engine on </em><a href="https://github.com/cloudstic/cli"><em>GitHub</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e6f26ecc237" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Anatomy of Modern Incremental Backups]]></title>
            <link>https://medium.com/@loichrn/the-anatomy-of-modern-incremental-backups-f76bd3e155e5?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/f76bd3e155e5</guid>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[merkle-tree]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 19:07:38 GMT</pubDate>
            <atom:updated>2026-03-16T20:36:23.028Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0h4QZQZlpDhTo1KyZDi4g.png" /></figure><p>If you have ever tried to back up a terabyte of data to the cloud, you know the naive approach of copying everything every time is a disaster. It is slow, expensive, and kills your bandwidth. To solve this, the industry moved to incremental backups where only changed data is uploaded. However, as data scales into the petabytes, the standard way of doing incrementals is hitting a wall.</p><p>In this article, we look at the state of the art techniques used by modern storage engines and why the next generation of backup tech is moving toward a more flexible, flat architecture.</p><p>Originally published on my blog:<br><a href="https://blog.cloudstic.com/2026/03/11/the-anatomy-of-modern-incremental-backups/">https://blog.cloudstic.com/2026/03/11/the-anatomy-of-modern-incremental-backups/</a></p><h3>1. Content Addressable Storage (CAS)</h3><p>The biggest leap in modern backup architecture is abandoning files and folders at the storage layer. Instead, industry leaders use Content Addressable Storage (CAS). In a traditional system, data is found by its path.</p><p>In CAS, data is found by its cryptographic hash such as SHA-256.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adjwqC6PCGASi8iexhHhDQ.png" /><figcaption>Figure 1: Content-Addressable Storage (CAS) vs. Traditional Location-Based Addressing.*</figcaption></figure><p>The CAS logic is simple. Same content leads to the same hash which is stored once. This is the foundation of deduplication. If you rename a file or move it to a different folder, a CAS based system realizes the content has not changed and uploads exactly zero bytes.</p><h4>The Confirmation Attack</h4><p>Standard CAS has a privacy hole. If a cloud provider knows the hash of a specific file, they can see if your bucket contains that hash even if they cannot read the encrypted content.</p><p>To solve this, one solution is to avoid using raw hashes for chunk names. Instead, we can use Keyed HMAC-SHA256. By using a secret key known only to you to salt the hashes, your data remains fully deduplicated but becomes cryptographically opaque to the host.</p><h4>The Boundary Shift Problem</h4><p>What if you have a 10GB database and change one single row?</p><p>Slicing it at fixed 1MB intervals is a trap. If you insert one byte at the very beginning, every 1MB boundary shifts. This changes the hash of every block.</p><h4>The Solution: Content Defined Chunking (CDC)</h4><p>Modern systems use algorithms like FastCDC. It rolls a sliding window across the data. When the data matches a specific mathematical pattern, it slices the chunk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8FNR64CLakH1C4XZR28Ww.png" /><figcaption>Figure 2: CDC Chunking compared to Fixed size Chunking</figcaption></figure><p>Because the boundaries are determined by the content itself, an insertion at the start only changes the first chunk. The rest of the puzzle pieces realign perfectly.</p><h3>2. Structural Sharing: The Magic of Merkle Trees</h3><p>Once you have thousands of content addressed chunks, you must remember which chunks belong to which files at a specific point in time. The industry standard is the Merkle Tree. This is a hierarchical structure where every node is the hash of its children. This enables Structural Sharing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PcFiJ1KA8_pctiRxWhAnmg.png" /><figcaption>Figure 3: Structural Sharing via Merkle Trees</figcaption></figure><p>When you take a new backup:</p><ul><li>You only upload the modified chunks.</li><li>A new root hash is generated for the snapshot.</li><li>Most of the tree simply points to the previous snapshot’s nodes.</li></ul><p>The result is that every snapshot acts like a full backup for recovery, but it only consumes the storage space of an incremental update.</p><h3>3. The Directory Tree Trap</h3><p>Most modern tools build their Merkle Trees by mirroring the computer’s natural directory structure. While intuitive, this path based approach creates two major headaches at scale.</p><p><strong>Path Amplification:</strong> If you have a file buried ten folders deep, changing that one file forces the system to recalculate and reupload metadata for all ten parent directories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4z7Jtvfc2lcGcs0mQGV6HA.png" /></figure><p><strong>The Rigid Hierarchy Problem:</strong> Modern data does not always live in a neat tree. Cloud drives like Google Drive allow a single file to have multiple parents, and flat data streams like database dumps do not have folders at all. Standard tools struggle to map these non tree structures efficiently, which often leads to metadata bloat.</p><h3>4. About the Author</h3><p>I have been looking into these industry standards while building <a href="https://docs.cloudstic.com/introduction">Cloudstic</a>, a project aimed at solving these specific bottlenecks. To achieve both zero trust privacy and high performance, I realized the engine needed to be built from the ground up.</p><p>Cloudstic is a content addressable, encrypted CLI backup tool designed to be fully stateless. Unlike many traditional tools, it can back up from Google Drive and OneDrive using incremental APIs without ever needing to mount the drive.</p><h4>Core Features:</h4><ul><li><strong>Encrypted by Default:</strong> Uses AES-256-GCM encryption with password, platform key, or recovery key slots.</li><li><strong>Content Addressable:</strong> Native deduplication across all sources; identical files are stored only once.</li><li><strong>Versatile Backends:</strong> Supports local filesystems, Amazon S3 (R2, MinIO), and Backblaze B2.</li><li><strong>Smart Retention:</strong> Automated keep-last, hourly, daily, and yearly retention policies.</li><li><strong>Point-in-Time Restore:</strong> Instant access to any snapshot or file from any point in history.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f76bd3e155e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebAuthn HTTP Signature]]></title>
            <link>https://medium.com/@loichrn/webauthn-http-signature-8c9bf4e6e734?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c9bf4e6e734</guid>
            <category><![CDATA[signature]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webauthn]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Fri, 30 May 2025 19:09:12 GMT</pubDate>
            <atom:updated>2025-05-30T19:09:12.431Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iazdcIRfrCkRPlYNmE1t2g.png" /></figure><p>HTTP Message Signing and it’s cousin DPoP solved a big problem for native and mobile apps: they let the client prove, on every call, that it holds a hardware-bound key and that a real person just approved the request. The catch is that those schemes assume the app can mint a key inside a Secure Enclave or TPM. That is easy when you control the runtime, impossible when your code runs inside a browser tab. For years that limitation steered high-risk vendors, commercial banks, crypto exchanges, and security vendors toward thick clients instead of web apps because the browser offered no elegant way to reach the same cryptographic bar.</p><p>WebAuthn changes the equation. Its predominate usecase is passwordless login, but the API also gives us one crucial primitive: “sign this 32-byte challenge with a key the user keeps in protected hardware, and make them tap or scan to prove they are present.” That is exactly what HTTP Signature and DPoP need. By feeding a structured HTTP signing string into WebAuthn and stuffing the resulting assertion back into the request headers, we can give any fetch call the same proof-of-possession guarantees that native apps enjoy.</p><p>This post shows how to wire the two standards together so every outbound request from a browser carries its own hardware-signed, replay-proof credential. We will walk through the flow, drop in a TypeScript helper you can copy today, and cover the sharp edges you need to watch on the server.</p><p>Git repo: <a href="https://github.com/rmanibus/Webauthn-Http-Signature">https://github.com/rmanibus/Webauthn-Http-Signature</a></p><h3>Why WebAuthn + HTTP Signatures?</h3><ul><li><strong>True in-browser key access</strong></li></ul><p>Browsers don’t let you poke at raw private keys, WebAuthn is the <em>only</em> standardized, secure API that does. By folding WebAuthn into HTTP Message Signatures, we can sign requests <em>directly</em> in the browser without ever exposing secret material to JavaScript. WebAuthn keys live in TPMs, Secure Enclaves, or USB security keys, making it impossible for malicious scripts to exfiltrate your private key.</p><ul><li><strong>Sessionless, cryptographic authentication</strong></li></ul><p>Instead of sending cookies or bearer tokens, each request carries its own proof of authenticity. This is perfect for high-value operations, everything’s stateless and verifiable.</p><ul><li><strong>Built-in replay protection</strong></li></ul><p>We derive each WebAuthn challenge by hashing the structured signature input <strong>and include a short-lived, server-generated nonce in the signature parameters</strong>. The server must issue a fresh nonce per request and verify it when validating the WebAuthn assertion to guarantee each signed request is unique and thwarts replay attacks.</p><ul><li><strong>User presence &amp; verification</strong></li></ul><p>By requiring <strong>user presence</strong> (e.g. touching a security key) or <strong>user verification</strong> (e.g. biometric or PIN), you can ensure that each signed request was explicitly approved by the user. The server can check these flags to enforce policies, guaranteeing that a human action, not just a headless script, authorized the operation.</p><blockquote><em>Use case spotlight: Imagine a bank’s “transfer funds” endpoint that normally would rely on a session cookie. With this approach, the browser signs the transfer request directly. Because WebAuthn can demand a fingerprint or button-tap, the server knows the user actively approved that transfer. No session state, no CSRF tokens, and no “remember me” tokens floating around.</em></blockquote><h3>The High-Level Flow</h3><ol><li><strong>Build the Signature Input</strong></li></ol><p>Concatenate covered fields (e.g., @method, @path, content-digest) into a single UTF-8 string as per the spec.</p><p><strong>2. Hash → Challenge</strong></p><pre>const input = `&quot;@method&quot;: POST\n&quot;@path&quot;: /api/foo\n&quot;@signature-params&quot;: ...`;<br>const rawHash = await crypto.subtle.digest(&quot;SHA-256&quot;, new TextEncoder().encode(input));</pre><p><strong>3. WebAuthn Ceremony</strong></p><pre>const credential = await navigator.credentials.get({<br>  publicKey: {<br>    challenge: rawHash,<br>    allowCredentials, // optional<br>    userVerification: &quot;preferred&quot;<br>  }<br>});</pre><p><strong>4. Serialize &amp; Base64-URL Encode</strong></p><pre>const json = JSON.stringify(credential);<br>const signatureValue = btoa(json)  // or use a proper base64url lib<br>  .replace(/\+/g, &quot;-&quot;).replace(/\//g, &quot;_&quot;).replace(/=+$/, &quot;&quot;);</pre><p><strong>5. Send HTTP Headers</strong></p><pre>Signature-Input: sig1=(&quot;@method&quot; &quot;@path&quot; &quot;content-digest&quot;);alg=&quot;webauthn&quot;;created=…;expires=…;nonce=&quot;…&quot;<br>Signature:       sig1=:{signatureValue}:</pre><h3>Frontend Primer: A Tiny Try-It-Yourself Library</h3><p>Here’s a slimmed-down TypeScript helper to get you started. Copy &amp; paste away! (For a full-featured implementation with extra options check out the complete version in our GitHub repo: <a href="https://github.com/rmanibus/Webauthn-Http-Signature">https://github.com/rmanibus/Webauthn-Http-Signature</a>)</p><pre>// webauthn-http-sig.ts<br>export async function signWithWebAuthn(<br>  req: Request,<br>  {<br>    components,<br>    nonce = crypto.getRandomValues(new Uint8Array(16)).toString(),<br>    maxAgeSec = 60<br>  }: {<br>    components: string[];<br>    nonce?: string;<br>    maxAgeSec?: number;<br>  }<br>): Promise&lt;Request&gt; {<br>  // 1. Build signature input string<br>  const lines = components.map(h =&gt;<br>    h.startsWith(&quot;@&quot;)<br>      ? `&quot;${h}&quot;: ${derive(h, req)}`<br>      : `&quot;${h}&quot;: ${req.headers.get(h) || &quot;&quot;}`<br>  );<br>  const created = Math.floor(Date.now() / 1000);<br>  const expires = created + maxAgeSec;<br>  const params = `(&quot;${components.map(h =&gt; h).join(&#39;&quot; &quot;&#39;)}&quot;);alg=&quot;webauthn&quot;;created=${created};expires=${expires};nonce=&quot;${nonce}&quot;`;<br>  lines.push(`&quot;@signature-params&quot;: ${params}`);<br>  const signingString = lines.join(&quot;\n&quot;);<br><br>  // 2. Challenge = SHA-256 hex<br>  const raw = await crypto.subtle.digest(&quot;SHA-256&quot;, new TextEncoder().encode(signingString));<br>  const hex = Array.from(new Uint8Array(raw))<br>    .map(b =&gt; b.toString(16).padStart(2, &quot;0&quot;))<br>    .join(&quot;&quot;);<br><br>  // 3. WebAuthn assertion<br>  const cred = await navigator.credentials.get({<br>    publicKey: { challenge: Uint8Array.from(hex.match(/.{2}/g)!, b =&gt; parseInt(b, 16)) }<br>  });<br><br>  // 4. Encode and set headers<br>  const sig = btoa(JSON.stringify(cred)).replace(/\+/g, &quot;-&quot;).replace(/\//g, &quot;_&quot;).replace(/=+$/, &quot;&quot;);<br>  req.headers.set(&quot;Signature-Input&quot;, `sig1=${params}`);<br>  req.headers.set(&quot;Signature&quot;, `sig1=:${sig}:`);<br>  return req;<br>}<br><br>function derive(comp: string, req: Request): string {<br>  const url = new URL(req.url);<br>  switch (comp) {<br>    case &quot;@method&quot;: return req.method;<br>    case &quot;@path&quot;:   return url.pathname;<br>    case &quot;@authority&quot;: return url.host;<br>    default: throw Error(`Unsupported ${comp}`);<br>  }<br>}</pre><blockquote><em>Pro tip: If you cover content-digest, compute it first (e.g. SHA-512 of the body) and set the header before calling signWithWebAuthn.</em></blockquote><h3>Server-Side Verification Sketch</h3><p>On the server:</p><ol><li><strong>Parse</strong> Signature-Input &amp; Signature headers.</li><li><strong>Base64-URL decode</strong> the signature to JSON → PublicKeyCredential.</li><li><strong>Extract</strong> response.clientDataJSON, response.authenticatorData, response.signature.</li><li><strong>Recompute</strong> SHA-256 of clientDataJSON → must match the original hex challenge.</li><li><strong>Verify</strong> the assertion per <a href="https://www.w3.org/TR/webauthn-2/#sctn-assertion-signature">W3C-WebAuthn §7.3.4</a>.</li><li><strong>Rebuild</strong> the HTTP signing string from covered fields and ensure it matches what the client signed.</li></ol><p>Most WebAuthn libraries (in Go, Node.js, Python, etc.) give you functions to validate the assertion; you just feed them the raw pieces plus your stored public key.</p><h3>Security Considerations</h3><ol><li><strong>Server-Generated Nonce</strong></li></ol><ul><li><strong>Why?</strong> A fresh, unpredictable nonce prevents an attacker from replaying a previously signed assertion.</li><li><strong>How?</strong> For each HTTP request, have your server generate a random nonce (e.g. 16–32 bytes), include it in the Signature-Input parameters (;nonce=&quot;&lt;base64url&gt;&quot;), and embed it in the WebAuthn challenge.</li><li><strong>Verify:</strong> On receipt, the server must check that the nonce matches the one it issued — and that it hasn’t been used before.</li></ul><p><strong>2. Tight Timestamps (</strong><strong>created &amp; </strong><strong>expires)</strong></p><ul><li><strong>Why?</strong> Limits the window for an intercepted signature to be replayed.</li><li><strong>How?</strong> Add ;created=&lt;unix-secs&gt; and ;expires=&lt;unix-secs&gt; to the Signature-Input and derive your WebAuthn challenge over the entire input string. Use a short TTL (e.g. 30–60 seconds).</li><li><strong>Verify:</strong> Reject any assertion where now &lt; created or now &gt; expires.</li></ul><p><strong>3. Content-Digest Integrity</strong></p><ul><li><strong>Why?</strong> Ensures that the HTTP body hasn’t been tampered with between signing and verification.</li><li><strong>How?</strong> If the client covers content-digest in its components, compute the digest (e.g. sha-512) client-side, include that header, and cover it in the signature.</li><li><strong>Verify:</strong> Server must recompute the same hash over the received body and reject the request if it doesn’t match the Content-Digest header.</li></ul><p><strong>4. Enforcing User Presence &amp; Verification</strong></p><ul><li><strong>Why?</strong> Guarantees a real human approved the request, not just a script.</li><li><strong>How?</strong> In your WebAuthn publicKey options, set:</li></ul><pre>authenticatorSelection: {<br>  userVerification: &#39;required&#39;, // biometric or PIN<br>  requireResidentKey: false<br>},<br>userVerification: &#39;required&#39;</pre><ul><li>The browser will then prompt for a fingerprint, PIN, or platform authenticator tap.</li><li><strong>Verify:</strong> On the server, parse the assertion’s authenticatorData.flags to ensure the <strong>UP</strong> (User Present) and <strong>UV</strong> (User Verified) bits are set.</li></ul><p><strong>5. Credential Lifecycle &amp; Revocation</strong></p><ul><li><strong>Why?</strong> Lost or compromised authenticators must be disabled.</li><li><strong>How?</strong> When extracting the credential id from the WebAuthn response, look it up in your database of valid credentials.</li><li><strong>Verify:</strong> Reject any assertion whose credential ID is not recognized or has been revoked.</li></ul><h3>Give It a Spin</h3><ol><li><strong>Clone</strong> this repo and npm install.</li><li>Hook the helper into a minimal HTML page that does fetch(&quot;/api/echo&quot;, { …signed… }).</li><li>On your server, log out the parsed PublicKeyCredential to watch WebAuthn in action.</li></ol><p>If your browser prompts for Touch ID, a USB key blink, or a PIN, congratulations: you’ve just signed an HTTP request with hardware crypto!</p><h3>About Me</h3><p>I am an engineer specializing in authentication, currently part of the R&amp;D team at Kandji, where I help design secure, scalable systems for device and user trust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c9bf4e6e734" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Toujours plus loin, toujours plus haut, toujours plus fort avec Java, partie 1: Coder à la vitesse…]]></title>
            <link>https://medium.com/sciam-fr/toujours-plus-loin-toujours-plus-haut-toujours-plus-fort-avec-java-partie-1-coder-%C3%A0-la-vitesse-1c2094c1912f?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2094c1912f</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Wed, 29 Sep 2021 14:37:58 GMT</pubDate>
            <atom:updated>2021-09-29T14:37:58.307Z</atom:updated>
            <content:encoded><![CDATA[<h3>Toujours plus loin, toujours plus haut, toujours plus fort avec Java, partie 1: Coder à la vitesse de l’éclair</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wP4DCPy7MxRbZGkCQ1y7tw.jpeg" /></figure><p>Dans cette série de trois articles, je souhaite vous dresser un panorama des évolutions majeures autour de Java au cours de ces dernières années.</p><p>Parmi les nombreuses évolutions qui pourraient vous pousser à vouloir découvrir les version récentes du langage, celles que je trouve particulièrement intéressantes sont celles permettant d’améliorer la vitesse de développement et la lisibilité du code.</p><p>Je vous propose donc d’entrevoir à travers cet article les nouveautés du langage Java qui ont amélioré l’expérience de développement en rendant la syntaxe du code toujours plus concise et plus lisible.</p><h3>JEP 361: Switch Expressions</h3><p>Cette JEP introduit une nouvelle syntaxe pour les switch case depuis la version 14 de java.</p><p>Cette syntaxe n’utilise plus le mot clé break, et il est possible de lister plusieurs labels au sein d’un seule case.</p><p>Ainsi le code suivant:</p><pre>switch (day) {<br>    case MONDAY:<br>    case FRIDAY:<br>    case SUNDAY:<br>        System.out.println(&quot;six&quot;);<br>        break;<br>    case TUESDAY:<br>        System.out.println(&quot;sevent&quot;);<br>        break;<br>    case THURSDAY:<br>    case SATURDAY:<br>        System.out.println(&quot;eight&quot;);<br>        break;<br>    case WEDNESDAY:<br>        System.out.println(&quot;nine&quot;);<br>        break;<br>}</pre><p>se trouve ainsi réduit:</p><pre>switch (day) {<br>    case MONDAY, FRIDAY, SUNDAY -&gt; System.out.println(&quot;six&quot;);<br>    case TUESDAY                -&gt; System.out.println(&quot;seven&quot;);<br>    case THURSDAY, SATURDAY     -&gt; System.out.println(&quot;eight&quot;);<br>    case WEDNESDAY              -&gt; System.out.println(&quot;nine&quot;);<br>}</pre><p>De plus, il est maintenant possible d’utiliser le switch comme une expression. Ainsi, On pourra encore simplifier le morceau de code précedent en utilisant qu’une fois le println:</p><pre>System.out.println(<br>        switch (k) {<br>            case MONDAY, FRIDAY, SUNDAY -&gt; &quot;six&quot;;<br>            case TUESDAY                -&gt; &quot;seven&quot;;<br>            case THURSDAY, SATURDAY     -&gt; &quot;eight&quot;;<br>            case WEDNESDAY              -&gt; &quot;nine&quot;;<br>        }<br>    );</pre><p>si la partie de droite d’un case devait contenir un bloc avec plusieurs expression, le resultat peut être retourner avec le nouveau mot clé “yield”:</p><pre>System.out.println(<br>        switch (k) {<br>            case MONDAY, FRIDAY, SUNDAY -&gt; &quot;six&quot;;<br>            case TUESDAY                -&gt; &quot;seven&quot;;<br>            case THURSDAY, SATURDAY     -&gt; &quot;eight&quot;;<br>            case WEDNESDAY              -&gt; {  <br>                                            //do some stuff<br>                                            yield &quot;nine&quot;<br>                                          };<br>        }<br>    );</pre><h3>JEP 395: Records</h3><p>Disponible en preview depuis java 14 et officiellement intégrés à la version 16 du langage, les records ont pour ambition de faciliter l’écriture de classes servant uniquement à transporter de la donnée immuable (DTO par exemple).</p><p>Pour le compilateur, il s’agit simplement d’un nouveau type de classe composée:</p><p>d’un constructeur dont la signature est la même que le header,</p><ul><li>une implémentation de la méthode équals</li><li>une implémentation de la méthode hashcode</li><li>une implémentation de la methode toString</li></ul><p>et pour chaque élément dans le header :</p><ul><li>un getter public</li><li>un attribut final et privé.</li></ul><p>Afin de se rendre compte du gain de place engendré par cette JEP, voici deux déclarations équivalente:</p><pre>class Point {<br>    private final int x;<br>    private final int y;<br><br>    Point(int x, int y) {<br>        this.x = x;<br>        this.y = y;<br>    }<br><br>    int x() { return x; }<br>    int y() { return y; }<br><br>    public boolean equals(Object o) {<br>        if (!(o instanceof Point)) return false;<br>        Point other = (Point) o;<br>        return other.x == x &amp;&amp; other.y == y;<br>    }<br><br>    public int hashCode() {<br>        return Objects.hash(x, y);<br>    }<br><br>    public String toString() {<br>        return String.format(&quot;Point[x=%d, y=%d]&quot;, x, y);<br>    }<br>}</pre><pre>record Point(int x, int y) { }</pre><p>Il sera bien-sûr possible d’ajouter au record d’autre méthodes ou constructeurs.</p><h3>JEP 394: Pattern Matching for instanceof</h3><p>Cette JEP fait son apparition dans la version 16 du langage. Celle-ci permet d’économiser une ligne de code à chaque fois.</p><pre>if (obj instanceof String) {<br>    String s = (String) obj;    // grr...<br>    s.split(&quot;,&quot;)<br>}</pre><p>En effet dans le bloc ci-dessus, le cast est redondant, mais nécessaire dans les précédentes versions de java.</p><p>Ainsi dans l’exemple suivant, à l’intérieur du bloc “if” on pourra utiliser la nouvelle variable “s” ayant comme type String en s’abstrayant du cast.</p><pre>if (obj instanceof String s) { <br> <strong>   </strong>s.split(&quot;,&quot;)<br>}</pre><p>Même si le gain ne saute pas aux yeux directement avec cet exemple, il reste néanmoins conséquent pour les gros projets, d’autant plus que la lisibilité se trouve grandement améliorée par cet artefact.</p><p>Cette JEP sera completée par une autre JEP permettant le pattern matching au seins d’un switch case. Cette fonctionnalité est d’ores et déjà présente en preview dans le jdk 17 à travers la JEP 406: Pattern Matching for switch (Preview).</p><h3>JEP 378: Text Blocks</h3><p>Disponible depuis java 15, cette fonctionnalité facilite grandement l’écriture de bloc de text multi-ligne.</p><p>Avant cette JEP, pour introduire un bloc de text dans le code on pouvait faire quelque chose comme ça:</p><pre>String s = &quot;It was the best of times, it was the worst of times,\n&quot;<br>         + &quot;it was the age of wisdom, it was the age of foolishness,\n&quot;<br>         + &quot;it was the epoch of belief, it was the epoch of incredulity,\n&quot;<br>         + &quot;it was the season of Light, it was the season of Darkness,\n&quot;<br>         + &quot;it was the spring of hope, it was the winter of despair,\n&quot;<br>         + &quot;we had everything before us, we had nothing before us&quot;;</pre><p>Très peu lisible me direz vous.</p><p>Avec cette JEP la syntaxe suivante est désormais possible:</p><pre>String s = &quot;&quot;&quot;It was the best of times, it was the worst of times,<br>it was the age of wisdom, it was the age of foolishness,<br>it was the epoch of belief, it was the epoch of incredulity,<br>it was the season of Light, it was the season of Darkness,<br>it was the spring of hope, it was the winter of despair,<br>we had everything before us, we had nothing before us&quot;&quot;&quot;;</pre><p>Cette nouvelle syntaxe gère automatiquement les retours àla ligne (plus de “/n”), ainsi que l’indentation.</p><p>Ainsi le texte retourné par la méthode suivante sera indenté correctement. les espaces en trop en début et en fin de ligne sont supprimés. le bloc html de notre exemple sera donc décalé de 12 caractères par le compilateur.</p><pre>public String getBlockOfHtml() {<br>    return &quot;&quot;&quot;<br>            &lt;html&gt;<br><br>                &lt;body&gt;<br>                    &lt;span&gt;example text&lt;/span&gt;<br>                &lt;/body&gt;<br>            &lt;/html&gt;&quot;&quot;&quot;;<br>}</pre><p>Cette liste n’a pas la prétention d’être pas exhaustive, j’espère qu’elle vous aura au tout de même permise d’entrevoir l’ampleur des évolutions ayant eu lieu sur le langage, et a quel point ces évolutions permettent d’améliorer l’expérience du développeur.</p><p>On se retrouve bientôt pour deux autres articles abordant le sujet sous l’angle de la performance puis de la sécurité.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2094c1912f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sciam-fr/toujours-plus-loin-toujours-plus-haut-toujours-plus-fort-avec-java-partie-1-coder-%C3%A0-la-vitesse-1c2094c1912f">Toujours plus loin, toujours plus haut, toujours plus fort avec Java, partie 1: Coder à la vitesse…</a> was originally published in <a href="https://medium.com/sciam-fr">SCIAM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quarkus : comment créer un Bean virtuel en 3 étapes]]></title>
            <link>https://medium.com/sciam-fr/quarkus-comment-cr%C3%A9er-un-bean-virtuel-en-3-%C3%A9tapes-8e4113d8ec6b?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4113d8ec6b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[quarkus]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Tue, 02 Jun 2020 08:28:41 GMT</pubDate>
            <atom:updated>2020-06-02T08:28:41.927Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quarkus : comment créer un Bean virtuel en 3 étapes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dJsSu-CJqBP7nSlHegFfg.jpeg" /><figcaption>Image par <a href="https://pixabay.com/fr/users/TheDigitalArtist-202249/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4246668">Pete Linforth</a> de <a href="https://pixabay.com/fr/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=4246668">Pixabay</a></figcaption></figure><p><a href="https://medium.com/sciam-fr/story-2-54b087608754">J’ai</a> eu l’occasion de m’intéresser récemment au framework Quarkus qui est une implémentation <strong>JEE Microprofile</strong> pour <strong>faciliter le développement de</strong> <a href="https://fr.wikipedia.org/wiki/Microservices"><strong>micro-services</strong></a>.</p><p>Ce framework, dont la vocation est d’être extrêmement rapide (subatomic supersonic java …), permet la création d’<strong>extensions</strong> en déplaçant au maximum la logique dans le build, ce qui permet un boot ultra rapide. Pour commencer à écrire des extensions, la documentation d’origine est très claire : <a href="https://quarkus.io/guides/writing-extensions">https://quarkus.io/guides/writing-extensions</a></p><p>La partie peu documentée qui m’a intéressée est la suivante : comment créer un <strong><em>Bean</em> </strong>virtuel (<strong>interface<em> </em></strong>injectable sans implémentation explicite) à l’aide d’une extension. Ce type de <strong><em>Bean </em></strong>est plus connu sous le nom de <strong><em>Synthetic Bean.</em></strong></p><h3>Etape 1 : injecter les interfaces annotées</h3><p>Premièrement, notons que Quarkus n’utilise pas Weld (l’implémentation de référence de la spécification CDI) mais Arc, sa propre implémentation orientée build time.</p><p>Je vous propose de commencer par étudier un simple plugin permettant de faire du RPC au dessus de Map Hazelcast : <a href="https://github.com/rmanibus/rcast-project">Rcast</a>.</p><p>Il s’agit de pouvoir injecter les interfaces annotées @RegisterRcast <strong>sans fournir d’implémentation réelle</strong>. Sous le capot, nous fournissons simplement un proxy sur l’interface pour faire l’appel RPC.</p><p>Soit l’interface suivante :</p><pre>@RegisterRcast(appName = &quot;the-app&quot;)<br>public interface MyService {<br>    String method1(String arg1);<br>}</pre><p>Pouvant être utilisée de la sorte :</p><pre>@ApplicationScopped<br>public class RcastExtTest {</pre><pre>    @Inject<br>    @Rcast<br>    MyService service;</pre><pre>    public void useThatService() {<br>        service.method1(&quot;the arg&quot;);<br>    }<br>}</pre><p>Dans ce cas de figure, il faudra qu’une implémentation existe sur l’application cible (“the app” ). Mais dans notre application, nous n’aurons besoin que de l’interface.</p><p>Pour indiquer clairement notre intention d’exploiter le service proxy, nous utiliserons le <strong><em>qualifier </em></strong>@Rcast. Sur le service cible, par exemple, cela évitera d’injecter le proxy dès lors que nous souhaitons obtenir directement l’implémentation.</p><p>Je vous invite ensuite à lire la documentation de Quarkus relative à la création de la coquille du projet. Suite à quoi vous devriez avoir deux modules dans votre projet : “runtime” et “deployment”. Le module “deployment” contiendra l’ensemble de la logique qui sera exécutée lors du build.</p><h3>Etape 2 : le BeanCreator</h3><p>Nous allons d’abord définir la classe servant de modèle pour nos <strong><em>synthetic beans</em></strong>. Celle ci doit se trouver dans le module “deployment” de votre projet et implémenter l’interface BeanCreator :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/670eac7b911d636b0013bd4f2cf59201/href">https://medium.com/media/670eac7b911d636b0013bd4f2cf59201/href</a></iframe><p>Notons que je récupère ici un bean CDI (RcastProvider) en appelant le beanManager. Si nous n’injectons pas quelque part RcastProvider dans l’application, il faudra qu’il soit annoté par @Unremovable afin qu’Arc ne le supprime pas lors de la création du contexte.</p><h3>Etape 3 : le BeanProcessor</h3><p>Nous avons maintenant besoin d’une classe <strong><em>Processor </em></strong>dans le module “deployment”. Cette classe contiendra les étapes (@BuildStep) nécessaires à la construction de nos Beans virtuels.</p><p>D’abord, nous allons nous servir de l’index jandex afin de lister les interfaces annotées par @RegisterRcast.</p><p>Nous allons donc créer la méthode suivante dans notre class Processor :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1661e51138d28367e96519ba8f72e7ee/href">https://medium.com/media/1661e51138d28367e96519ba8f72e7ee/href</a></iframe><p>Nous pouvons maintenant utiliser <a href="https://sciam.fr/fr/">notre méthode et notre modèle</a> au sein d’une BuildStep (méthode annotée au sein de la classe Processor, servant d’étape de construction, ces méthodes sont exécutées automatiquement par Quarkus).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da52b5d99710d6fd52da5a0073263c2c/href">https://medium.com/media/da52b5d99710d6fd52da5a0073263c2c/href</a></iframe><p><strong>Vous pouvez dès à présent injecter l’interface que nous avons créée au début de ce projet en ajoutant l’extension en dépendance de votre projet.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4113d8ec6b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sciam-fr/quarkus-comment-cr%C3%A9er-un-bean-virtuel-en-3-%C3%A9tapes-8e4113d8ec6b">Quarkus : comment créer un Bean virtuel en 3 étapes</a> was originally published in <a href="https://medium.com/sciam-fr">SCIAM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction au WebRTC]]></title>
            <link>https://medium.com/sciam-fr/story-2-54b087608754?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b087608754</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[webrtc]]></category>
            <category><![CDATA[technologie]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Sat, 30 Nov 2019 17:35:13 GMT</pubDate>
            <atom:updated>2019-12-17T16:48:18.422Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Image par Joshua Sortino" src="https://cdn-images-1.medium.com/max/749/1*yBy4R9YD0o7VXrwa-nSxIA.jpeg" /><figcaption>Image par Joshua Sortino</figcaption></figure><p>Le WebRTC est un outil dédié à la communication en temps réel. Alors que les solutions précédentes exploitaient des plugins propriétaires (exemple : flash) et n’étaient pas standardisées, le WebRTC est implémenté dans presque tous les navigateurs, et permet d’établir une conversation entre plusieurs clients en quelques lignes de code JavaScript.</p><h3>1. Un outil standard</h3><p>Le WebRTC ( <strong>Web Real-Time Communication</strong>) est une <a href="http://lists.w3.org/Archives/Public/public-webrtc/2012Oct/att-0076/realtime-media.html">API</a> Javascript de communication en temps réel, permettant des échanges directs entre plusieurs navigateurs (voix vidéo et data). Ce standard de la W3C (<strong>World Wide Web Consortium</strong>) et de l’IETF (<strong>Internet Engineering Task Force</strong>) dont les premières ébauches sont apparues courant 2011, est soutenu par Google, Mozilla et Opera. Il est déjà implémenté (à des stades différents) dans plusieurs navigateurs, ainsi que dans Android et iOS. A noter qu’il existe également une solution concurrente développée par Windows : <a href="http://html5labs.interoperabilitybridges.com/cu-rtc-web/cu-rtc-web.htm">CU-RTC-WEB</a>.</p><p>Le WebRTC s’appuie sur d’autres normes telles que STUN, ICE, TURN, DTLS, SRTP et issues du projet <a href="https://developers.google.com/talk/libjingle/developer_guide">libjingle</a>. Le canal de communication repose sur de l’UDP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M2aGjYuA9ss2EzxgE4mHjw.png" /><figcaption>Protocoles du Web à gauche et WebRTC à droite. Source: <a href="https://hpbn.co/assets/diagrams/f91164cbbb944d8986c90a1e93afcd82.svg">https://hpbn.co/assets/diagrams/f91164cbbb944d8986c90a1e93afcd82.svg</a></figcaption></figure><h3>2. Focus sur 3 APIs</h3><p>Les APIs mises en oeuvre par WebRTC ont 3 fonctions :</p><ul><li>acquérir les flux audio et vidéo</li><li>transmettre les flux audio et vidéo</li><li>transmettre des données arbitraires</li></ul><p><strong>2.1 PeerConnection</strong></p><p>Elle représente la connexion entre les 2 terminaux. Cette dernière est établie à l’aide d’un canal de signalement laissé au choix de l’utilisateur (websocket ..) sur lequel sont transmises des données issues du Protocol SDP, permettant d’obtenir les informations local sur la connexion (/ ! \ SDP est en cours de remplacement au sein de la norme WebRTC par le protocole JSEP).</p><p>Pour assurer la connexion à travers les NAT, l’API PeerConnection utilise les protocoles STUN, ICE et TURN.</p><p>Ces flux partagent les mêmes paquets de niveaux transport et donc partagent le même numéro de port pour que les flux de données et médias puissent être multiplexés sur cette connexion. Ainsi l’octet de l’entête UDP, indiquant la nature du contenu de la trame, permet d’identifier s’il s’agit d’une trame STUN (0 ou 1), SRTP (20 à 63) ou DTLS (128 à 191).</p><p><strong>2.2 DataChannel</strong></p><p>Elle permet de transmettre des données génériques entre les terminaux (texte, image …). Ces dernières sont transmises à l’aide du protocole SCTP, lui-même reposant sur le protocole DTLS, afin d’assurer la confidentialité et l’authenticité des paquets.</p><p>L’API permet aussi d’assurer la gestion bidirectionnelle et de priorités entre plusieurs flux de données.</p><p><strong>2.3 MediaStream</strong></p><p>Elle représente un flux de données audio ou vidéo (local ou distant). L’accès à un flux local (WebCam, Micro) se fait grâce à l’API <strong>getusermedia</strong>.</p><p>Les flux sont transportés à l’aide du protocole SRTP implémentant une version sécurisé du protocole RTP. Il est à noter qu’un flux média exploite également DTLS pour la gestion des clés SRTP.</p><h3>3. Codec audio et vidéo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*GI6Yten0MjVI_B-S8aCPFw.jpeg" /><figcaption>Johnson Wang</figcaption></figure><p>La norme requière (au minimum) les codecs audio suivants : PCMA/PCMU correspondant au G711 respectivement alaw et ulaw, Telephone Event (RCF4733), Opus (RCF 6716).</p><p>Les critères auxquels le codec doit répondre sont :</p><ul><li>Support de fps compris entre 10 et 30</li><li>Support d’une résolution min 320 x 240 pixels</li></ul><p>On peut facilement contrôler les codecs implémentés dans différents navigateurs en analysant le SDP généré (à l’aide de testSdp.htm présent dans src/webrtc/sdp-exemple par exemple).</p><h3>4. Protocoles exploités par le WebRTC</h3><p><strong>4.1 SDP : signalement</strong></p><p>Pour créer une connexion, l’API PeerConnection exploite le protocole SDP (Session Description Protocol). Il permet de décrire la session multimédia en cours d’établissement.</p><p>Voici la signification des champs :</p><p><strong>Session description</strong></p><ul><li>v= (protocol version number, currently only 0)</li><li>o= (originator and session identifier : username, id, version number, network address)</li><li>s= (session name : mandatory with at least one UTF-8-encoded character)</li><li>i=* (session title or short information)</li><li>u=* (URL of description)</li><li>e=* (zero or more email address with optional name of contacts)</li><li>p=* (zero or more phone number with optional name of contacts)</li><li>c=* (connection information — not required if included in all media)</li><li>b=* (zero or more bandwidth information lines) <em>One or more </em><strong><em>Time descriptions</em></strong><em> (« t= » and « r= » lines; see below)</em></li><li>z=* (time zone adjustments)</li><li>k=* (encryption key)</li><li>a=* (zero or more session attribute lines) <em>Zero or more </em><strong><em>Media descriptions</em></strong><em> (each one starting by an « m= » line; see below)</em><strong>Time description</strong> (mandatory)</li><li>t= (time the session is active) r=* (zero or more repeat times)<strong>Media description</strong> (if present) m= (media name and transport address)</li><li>i=* (media title or information field)</li><li>c=* (connection information — optional if included at session level)</li><li>b=* (zero or more bandwidth information lines)</li><li>k=* (encryption key)</li><li>a=* (zero or more media attribute lines — overriding the Session attribute lines)</li></ul><p>Cette trame est généralement encapsulée dans du JSON. Le SDP est amené à disparaitre au profit du JSEP.</p><p><strong>4.2 Transport des données</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*7Aqe6iX1bTU3p8Fr6mWGTw.jpeg" /><figcaption><a href="https://unsplash.com/@andersjilden">Anders Jildén</a></figcaption></figure><p><strong><em>RTP</em></strong></p><p>RTP est un protocole destiné à transmettre sur de l’IP tout type de donnée ayant une contrainte de temps réel. Le principal service fourni par RTP est la numérotation des paquets ainsi que l’ajout de timestamp pour permettre de reconstituer correctement l’information.</p><p><strong><em>SRTP</em></strong></p><p>Le SRTP correspond à une version sécurisée du RTP.</p><p>Voici la signification des champs :</p><ul><li><strong>V</strong> version du protocole (V=2) sur 2 bits</li><li><strong>P</strong> Padding, sur 1 bit, vaut 1 si le dernier paquet contient un champ de bourrage</li><li><strong>X</strong> extension sur 1 bit, vaut 1 si l’en-tête est suivie d’un paquet d’extension</li><li><strong>CC</strong> sur 4 bits, nombre de CSRC qui suivent l’entête (CSRC count)</li><li><strong>M</strong> Marker sur 1 bit, son interprétation est définie par un profil d’application (profile)</li><li><strong>PT</strong> sur 7 bits, identifie le type du payload (audio, vidéo, image, texte, html…)</li><li><strong>Séquence number</strong> sur 16 bits, sa valeur initiale est aléatoire et il s’incrémente de 1 à chaque paquet envoyé ;il peut servir à détecter des paquets perdus</li><li><strong>Timestamp</strong> sur 32 bits, reflète l’instant où le premier octet du paquet RTP a été échantillonné</li><li><strong>SSRC</strong> sur 32 bits, valeur choisie de manière aléatoire par l’application qui identifie de manière unique la source</li><li><strong>Champ CSRC</strong> : 32 bits, identifie les sources contribuant</li></ul><p><strong><em>SCTP</em></strong></p><p>Le protocole SCTP est employé par l’API dataStream. Il est utilisé pour échanger des données n’étant pas de la vidéo ou du son.</p><p><strong>4.3 Sécurité</strong></p><p>Le protocole DTLS (Datagram Transport Layer Security) est basé sur le protocole TLS et fournit des garanties de sécurité similaires.</p><p><strong>4.4 Network Adress Translation</strong></p><p><strong><em>STUN</em></strong></p><p>Littéralement Simple Traversal of UDP through NATs. Ce protocole permet d’obtenir son adresse IP publique. Il s’agit d’un serveur léger consommant peu de ressources. Les données ne passent pas par le serveur.</p><p>Entête STUN :</p><p>Le champ Type codé sur 16 bits se découpe en plusieurs sous champ :</p><ul><li>Les deux premiers bits sont à 0 pour se différencier des autres protocoles</li><li>La classe sur 2 bits (00 Requête, 01 Indication, 10 Réponse avec succès, 11 Réponse avec erreur)</li><li>La méthode sur 12 bits</li><li>Magic Cookie est un champ à valeur fixe</li><li>Transaction ID est choisie de manière aléatoire par le client (le serveur répète la valeur dans sa réponse)</li></ul><p><strong><em>ICE</em></strong></p><p>Littéralement Interactive Connectivity Establishment, il s’agit d’un framework dont l’objectif est de trouver le meilleur chemin pour chaque communication.</p><p><strong><em>TURN</em></strong></p><p>Litteralement Traversal Using Relays around NAT, ce protocole fourni une alternative cloud si la communication directe entre les terminaux n’est pas possible. Les données sont ainsi transmises au serveur qui relaye l’information.</p><h3>5. Sources</h3><p>Ce qui est implémenté : <a href="http://iswebrtcreadyyet.com/">http://iswebrtcreadyyet.com/</a></p><p>Wiki : <a href="https://fr.wikipedia.org/wiki/WebRTC">https://fr.wikipedia.org/wiki/WebRTC</a></p><p>Site du projet : <a href="http://www.webrtc.org/">http://www.webrtc.org/</a></p><p>Slides sur le WebRTC: <a href="http://io13webrtc.appspot.com/">http://io13webrtc.appspot.com</a></p><p>Draft IETF WebRTC: <a href="https://tools.ietf.org/wg/rtcweb/">https://tools.ietf.org/wg/rtcweb/</a></p><p>Draft W3C WebRTC : <a href="http://w3c.github.io/webrtc-pc/">http://w3c.github.io/webrtc-pc/</a></p><p>Doc SRTP : <a href="https://tools.ietf.org/html/rfc3711">https://tools.ietf.org/html/rfc3711</a></p><p>Doc SCTP : <a href="https://tools.ietf.org/html/rfc4960">https://tools.ietf.org/html/rfc4960</a></p><p>Doc SDP : <a href="https://tools.ietf.org/html/rfc4566">https://tools.ietf.org/html/rfc4566</a></p><p>Wiki SDP : <a href="https://en.wikipedia.org/wiki/Session_Description_Protocol">https://en.wikipedia.org/wiki/Session_Description_Protocol</a></p><h4>6. Bibliothèques (C/C++)</h4><p>Opus, libopus :<br>Pour encoder et décoder des trames OPUS, utile pour réaliser une Gateway.<br><a href="http://www.opus-codec.org/docs/opus_api-1.1.0.pdf">http://www.opus-codec.org/docs/opus_api-1.1.0.pdf</a></p><p>Jingle, Libjingle :<br><a href="https://developers.google.com/talk/libjingle/developer_guide">https://developers.google.com/talk/libjingle/developer_guide</a></p><p>SCTP:<br><a href="http://simplestcodings.blogspot.fr/2010/08/sctp-server-client-implementation-in-c.html">http://simplestcodings.blogspot.fr/2010/08/sctp-server-client-implementation-in-c.html</a></p><p>SDP:<br><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstsdpmessage.html">http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstsdpmessage.html</a></p><p>RTP/SRTP:<br><a href="http://gstreamer.freedesktop.org/">http://gstreamer.freedesktop.org/</a><br>ou libsrtp<br><a href="https://github.com/cisco/libsrtp">https://github.com/cisco/libsrtp</a><br>ou ffmpeg<br><a href="https://www.ffmpeg.org/">https://www.ffmpeg.org/</a></p><p>TLS/DTLS:<br><a href="http://tinydtls.sourceforge.net/">http://tinydtls.sourceforge.net/</a><br><a href="http://wolfssl.com/">http://wolfssl.com</a><br><a href="http://www.gnutls.org/">http://www.gnutls.org/</a><br><a href="https://www.openssl.org/">https://www.openssl.org/</a></p><p>UDP:<br>[tuto from Scratch] <a href="http://broux.developpez.com/articles/c/sockets/">http://broux.developpez.com/articles/c/sockets/</a><br>Cependant la SDL et Qt permettent de créer très facilement des connexions UDP</p><h4>7. Projets divers</h4><p><a href="http://www.openwebrtc.io/">http://www.openwebrtc.io/</a><br>[MCU] <a href="https://janus.conf.meetecho.com/">https://janus.conf.meetecho.com/</a><br>[MCU] <a href="http://www.kurento.org/">http://www.kurento.org/</a><br>[TUTO] <a href="http://www.html5rocks.com/fr/tutorials/webrtc/basics/">http://www.html5rocks.com/fr/tutorials/webrtc/basics/</a><br>[MCU] <a href="http://sourceforge.net/projects/mcumediaserver/">http://sourceforge.net/projects/mcumediaserver/</a> (support H.264 ?)<br><a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+WebRTC+Support">https://wiki.asterisk.org/wiki/display/AST/Asterisk+WebRTC+Support</a><br><a href="http://phono.com/">http://phono.com/</a><br><a href="https://github.com/EricssonResearch/openwebrtc/">https://github.com/EricssonResearch/openwebrtc/</a><br>[H.264] <a href="http://webrtcbook.com/sdp-h264.html">http://webrtcbook.com/sdp-h264.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b087608754" width="1" height="1" alt=""><hr><p><a href="https://medium.com/sciam-fr/story-2-54b087608754">Introduction au WebRTC</a> was originally published in <a href="https://medium.com/sciam-fr">SCIAM</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to mitigate OTP Relay Attacks ?]]></title>
            <link>https://medium.com/@loichrn/how-to-mitigate-otp-relay-attacks-43ad469a3c3c?source=rss-88975c4e81fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/43ad469a3c3c</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Loïc Hermann]]></dc:creator>
            <pubDate>Wed, 03 Apr 2019 10:49:30 GMT</pubDate>
            <atom:updated>2019-04-03T11:02:57.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to mitigate OTP Relay Attacks ?</h3><p>OTP push &amp; TOTP are great. They protect you from basic credential theft, for example if you have used the same password on two websites and one of them has leaked your credentials in clear text.</p><p>But they are not perfect. An attacker can easily make you accept a login request from a phishing website.</p><p>Let start with the OTP push.</p><p>You usually enter your login and password on the website, then the website trigger a push notification on your phone. This is basically a proof of possession because by clicking on the notification, you prove that you are in possession of the phone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuExP3s1fBOc-Hu_6XJT2A.jpeg" /></figure><p>Now let’s see how an attacker can defeat this scheme.</p><p>If the phishing website relay the credentials to the legitimate site, this will triggers a push notification on your phone. If you accept it, the attacker gain access to your private resource on the legitimate website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfN3Gv9QZEJfBnYh6xAU2g.jpeg" /></figure><p>Let’s see what is happening with a TOTP.</p><p>Basically, after entering your credentials, the website asks you to read a code on a mobile application. The key is derived from a private key and a time variable. This is also a proof of possession.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qfB3rBwxFmmvmjGaRPh6pg.jpeg" /></figure><p>This can also be defeated with a relay attack.</p><p>If you give the phishing website your OTP, the attacker will be able to replay it on the legitimate website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NW_kK1y_1DYQwMUVVvLe9Q.jpeg" /></figure><p>How can we mitigate this kind of attacks?</p><p>My first thought was to use a plug-in on the browser.</p><h4>Mitigation with OTP Push</h4><p>For the OTP Push, the only authentication data that you send from your browser is your password. The plug-in can be in charge to “scope” the password. In fact, the plug-in knows the current host. it can compute a token with the value:</p><p>token = hash (password + current_hostname)</p><p>The legitimate website can compute this token derived from the user password and this would be the proof that the user is on the legitimate website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ziiSOJJBzo4KfqO3_jLO9g.jpeg" /></figure><p>If the user is on a phishing website, the token computed by the plug-in would be hash(password+ “phishing-site.com”) and it won’t correspond with the token computed by the legitimate website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOFzmD7ZrLYOeF_mXHbcjw.jpeg" /></figure><h4>Mitigation with TOTP</h4><p>We can do the same thing for the TOTP, but this time on the browser we have two identity proof on the browser: the password, and the OTP.</p><p>We can use the plug-in to inject a scoped OTP.</p><p>this time the token value is:</p><p>token = hash(otp + current_host)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJiKE1rQZw03VKeKOb00_Q.jpeg" /></figure><p>Now if the user is visiting a phishing website, the OTP won’t match if it is relayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIVwV5Os5CxVXPLzV4n3gA.jpeg" /></figure><h4>Limits</h4><p>This is a first step to mitigate this kind of attacks, but if the phishing website fool the user to enter his password in cleartext, it can easily compute the scoped password.</p><p>An attacker can also fool the user to download a malicious plug-in.</p><p>However, in the corporate world you would probably prevents users to install browsers plug-ins.</p><p>Ideally this solution should be implemented directly in the browser.</p><h4>U2F/FIDO2</h4><p>U2F is an open source passwordless authentication standard that rely on hardware key (like yubikey) or TPM. It protects you from phishing because the client scope the authentication. When a login is performed, the key sign the challenge provided by the server, and the origin (the server domain on which the client is connected).</p><p>Eventually this will become a much stronger authentication scheme as the one I described, but it requires your users to have some hardware available.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43ad469a3c3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>