<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://infosec.xyz/feed.xml" rel="self" type="application/atom+xml" /><link href="https://infosec.xyz/" rel="alternate" type="text/html" /><updated>2026-03-01T14:42:17+00:00</updated><id>https://infosec.xyz/feed.xml</id><title type="html">Avengers Infosec</title><subtitle>Security Journey</subtitle><author><name>Avengers Infosec</name><email>severus@infosec.xyz</email></author><entry><title type="html">Fido2 and banking use cases</title><link href="https://infosec.xyz/security/fido2-banking/" rel="alternate" type="text/html" title="Fido2 and banking use cases" /><published>2024-03-24T03:45:58+00:00</published><updated>2024-03-24T03:45:58+00:00</updated><id>https://infosec.xyz/security/fido2-banking</id><content type="html" xml:base="https://infosec.xyz/security/fido2-banking/"><![CDATA[<h2 id="fido2-is-not-only-passwordless-authentication-but-also-it-can-sign-anything-you-need">Fido2 is not only passwordless authentication, but also it can sign anything you need.</h2>
<p>Nowadays, we know Fido2 as passwordless authentication - which initializes authorized session. But in cryptography world, it’s useful for different purposes.</p>

<p>In my previous post, we know how fido2 works and its concept. If we see the signing method in a different way, we can use it for advanced authorization, and replace OTP - which something you know of.</p>

<h2 id="fido2-and-banking-domain-how-does-it-protect-users">Fido2 and banking domain, how does it protect users?</h2>
<p>If you use fido2 as passwordless authentication, how do you know that only authorized users connect to your system?<br />
In my previous post, again, when you implement fido2 on client side, you must define the way user uses platform authenticator or security key: user verification instead of user presence. It leads to choosing method of user verification.<br />
PIN and Password are something you know, only biometric is something you have. Then implementation must define biometric as primary of user verification.<br />
CTAP 2.1 supports enterprise assertion, bank will know the key they manage and deliver to user as RSA token before.<br />
For bank with custom implementation of Fido2 in their applications, they must allow biometric user verification only.<br />
State of Bank Vietnam released new document about authentication method included fido2 when making transaction. It’s widely adopted now.</p>

<h2 id="fido2-the-replacement-of-otp">Fido2: the replacement of OTP</h2>
<p>When customer uses OTP as their verification method, OTP is reused somewhere, and that’s why malwares on Android or IOS need to read OTP code from sms or smart otp application.<br />
You need to remember that: what you know is what you reuse somewhere.<br />
But someone said that: OTP is something you have. No, it’s totally wrong. OTP belongs to the OTP system, not you. You are revealed to know and send it back to server like other secrets: password. That’s why it’s named: one time password/pin.</p>

<p>Based on fido2’s implementation, when user makes transaction, the challenge is sent to customer, and they prove that they have private key, and sign this challenge for transaction - it likes advanced OTP when user received the challenge, it’s combined with static secret key and generate 6-8 OTP number but in fido2, user never knows the signed message and cannot reuse it somewhere, thanks to signature counter parameter.</p>

<h2 id="conclusion">Conclusion</h2>
<p>When State of Bank Vietnam adopts fido2 as standard, developer should know how to implement it correctly. Modern secure system bases on something users have, behaviour detection, so on…You should get rid of password in the future.</p>]]></content><author><name>severus</name></author><category term="Security" /><category term="fido2" /><category term="security" /><category term="banking" /><category term="signing" /><summary type="html"><![CDATA[Fido2 is not only passwordless authentication, but also it can sign anything you need. Nowadays, we know Fido2 as passwordless authentication - which initializes authorized session. But in cryptography world, it’s useful for different purposes.]]></summary></entry><entry><title type="html">Certificate Transparency and Mobile Security</title><link href="https://infosec.xyz/mobile/certificate-transparency/" rel="alternate" type="text/html" title="Certificate Transparency and Mobile Security" /><published>2024-03-21T03:45:58+00:00</published><updated>2024-03-21T03:45:58+00:00</updated><id>https://infosec.xyz/mobile/certificate-transparency</id><content type="html" xml:base="https://infosec.xyz/mobile/certificate-transparency/"><![CDATA[<h2 id="introduce-about-certificate-transparency">Introduce about Certificate Transparency</h2>
<p>Web Public Key Infrastructure (Web PKI) helps us on privacy and security. Trusted Certificate Authorities issue certificates and we trust them by default. Although they must follow policy before they issue any cetificate,  they can still issue the certificate for wrong usage as: impersonate website or man in the middle.</p>

<p>Cetificate transparency allows us to monitor issued certificates and inspect them, detect any misissued certificate. Because it only appends logs, we can use this for many purposes: track history of certificates, detect new domain in real time, terminate insecure connection,…</p>

<h2 id="mobile-security-and-certificate-transparency">Mobile security and Certificate Transparency</h2>
<p>Purpose: replacement of SSL Pinning.</p>

<p>SSL Pinning is good choice, but when we replace the certificate, we must rebuild our application. Dynamic SSL Pinning is another choice to resolve this issue, but we need to maintain new PKI infra. In deep dive, dynamic ssl pinning embedded 1 static hash and pulls new hash, after that, it binds new hash to hash array.</p>

<p>The mobile app is limited version of web browser, then many features like OCSP, Certificate transparency are missing. Banking/Finance applications must check enviroment before running, and when it’s patched to fake safe environment, we need to prevent man in the middle between our application and api server. But how do we make it transparency without SSL Pinning?</p>

<p>In previous blog, I showed that JA3 can help us on our purpose. But it needs to rework TLS handshake algo. We have another choice, better implementation: Certificate Transparency.</p>

<p>When application initializes connection, after it received certificates from server, it needs to check Signed Certificate Timestamp (SCT). Google Chrome only allows certificate with atleast 2 SCT, mobile applications should follow this rule.</p>

<p>By default, all new certificates will include 2 SCT in their attribute.</p>

<p>With custom CA and self signed certificates, they doesn’t contain those SCTs. Therefore, it needs more step to break this protection.</p>]]></content><author><name>severus</name></author><category term="Mobile" /><category term="certificate" /><category term="transparency" /><category term="mobile" /><summary type="html"><![CDATA[Introduce about Certificate Transparency Web Public Key Infrastructure (Web PKI) helps us on privacy and security. Trusted Certificate Authorities issue certificates and we trust them by default. Although they must follow policy before they issue any cetificate, they can still issue the certificate for wrong usage as: impersonate website or man in the middle.]]></summary></entry><entry><title type="html">Fido notes</title><link href="https://infosec.xyz/security/fido-notes/" rel="alternate" type="text/html" title="Fido notes" /><published>2024-02-27T03:45:58+00:00</published><updated>2024-02-27T03:45:58+00:00</updated><id>https://infosec.xyz/security/fido-notes</id><content type="html" xml:base="https://infosec.xyz/security/fido-notes/"><![CDATA[<h2 id="u2f-vs-fido2">U2F vs Fido2</h2>
<p>Fido U2F is renamed to CTAP1.</p>

<p>FIDO UAF: FIDO Universal Authentication Framework.</p>

<p>WebAuthn: New API supports passwordless login, compatible with Fido U2F/UAF.</p>

<p>Fido2: CTAP2 + Webauthn + UserVerification.</p>

<p>CTAP2: CTAP1 + resident key. Because it does not have key managment, when it reachs limitation of keys’s number, it must be reset.</p>

<p>CTAP2.1: CTAP2 + resident key management + authenticator attestion.</p>

<p>WebAuthn: authentication implementation supports passwordless login, multi factor authentication.</p>

<p>The flow:<br />
Relying Party &lt;—&gt; WebAuthn &lt;—&gt; Browser/App &lt;—-&gt; CTAP &lt;—-&gt; Authenticator</p>

<h2 id="non-resident-key-vs-resident-key">Non-Resident Key vs Resident Key</h2>
<p>Non-Resident Key: Authenticator stores master key and creates seed to derive sub key (ephemeral key). The encrypted seed and public key are sent to server. Authenticator does not store any seed or information about Relying Party, then it can generate unlimited keys.</p>

<p>Resident Key: Authenticator stores master key and private key to storage. Based on limitation of storage, amount of Resident Keys are limited: eg 25 for Yubikey and 50 for VinCSS Fido2 key.</p>

<h3 id="implementation-of-non-resident-key-and-resident-key">Implementation of Non-Resident Key and Resident Key</h3>
<p>Non-Resident Key requires Relying Party lookup Credential ID on their side. Then user must enter their username before looking up. Server must verify that authenticator has any public key for current user unless user sends unlimited keys and performance would be degraded.</p>

<p>With FIDO2, Relying Party sends list of Credential ID and Authenticator looks up on their side. It improves time and authentication process. Relying Party must allow user to choose public key for multiple users on same authenticator like: acme@gmail.com or severus@gmail.com.</p>]]></content><author><name>severus</name></author><category term="Security" /><category term="fido2" /><category term="webauthn" /><category term="u2f" /><summary type="html"><![CDATA[U2F vs Fido2 Fido U2F is renamed to CTAP1. FIDO UAF: FIDO Universal Authentication Framework. WebAuthn: New API supports passwordless login, compatible with Fido U2F/UAF. Fido2: CTAP2 + Webauthn + UserVerification. CTAP2: CTAP1 + resident key. Because it does not have key managment, when it reachs limitation of keys’s number, it must be reset. CTAP2.1: CTAP2 + resident key management + authenticator attestion. WebAuthn: authentication implementation supports passwordless login, multi factor authentication.]]></summary></entry><entry><title type="html">Could I read your PIN/PASSWORD from platform authenticator?</title><link href="https://infosec.xyz/security/android-accessibility/" rel="alternate" type="text/html" title="Could I read your PIN/PASSWORD from platform authenticator?" /><published>2024-01-03T14:15:58+00:00</published><updated>2024-01-03T14:15:58+00:00</updated><id>https://infosec.xyz/security/android-accessibility</id><content type="html" xml:base="https://infosec.xyz/security/android-accessibility/"><![CDATA[<h2 id="android-accessibility-service">Android Accessibility Service</h2>
<p>Android provides accessibility service for disabilities people. This service can access all events on phone’s screen. The security hole is that it can access platform authenticator’s values: pin, password. It introduces downgrading from biometric to PIN/PASS and reduces the security of Passkey/Fido2 (builtin android support in app, not physical fido2 tokens).</p>

<h2 id="reproduce-the-flaw">Reproduce the flaw</h2>

<p>Android has UIAutomation class and command: uiautomator, I use uiautomator - it’s same as UIAutomation class but built as binary.</p>

<p>After enabling adb, on lock screen, run command:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell uiautomator events | <span class="nb">grep </span>Text
</code></pre></div></div>

<p>The result looks like:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>20:01-03 16:11:57.531 EventType: TYPE_VIEW_CLICKED<span class="p">;</span> EventTime: 387545686<span class="p">;</span> PackageName: com.android.systemui<span class="p">;</span> MovementGranularity: 0<span class="p">;</span> Action: 0<span class="p">;</span> ContentChangeTypes: <span class="o">[]</span><span class="p">;</span> WindowChangeTypes: <span class="o">[]</span> <span class="o">[</span> ClassName: android.view.ViewGroup<span class="p">;</span> Text: <span class="o">[</span>DEF, 3]<span class="p">;</span> ContentDescription: 3<span class="p">;</span> ItemCount: <span class="nt">-1</span><span class="p">;</span> CurrentItemIndex: <span class="nt">-1</span><span class="p">;</span> Enabled: <span class="nb">true</span><span class="p">;</span> Password: <span class="nb">false</span><span class="p">;</span> Checked: <span class="nb">false</span><span class="p">;</span> FullScreen: <span class="nb">false</span><span class="p">;</span> Scrollable: <span class="nb">false</span><span class="p">;</span> ImportantForAccessibility: <span class="nb">true</span><span class="p">;</span> AccessibilityDataSensitive: <span class="nb">false</span><span class="p">;</span> BeforeText: null<span class="p">;</span> FromIndex: <span class="nt">-1</span><span class="p">;</span> ToIndex: <span class="nt">-1</span><span class="p">;</span> ScrollX: 0<span class="p">;</span> ScrollY: 0<span class="p">;</span> MaxScrollX: 0<span class="p">;</span> MaxScrollY: 0<span class="p">;</span> ScrollDeltaX: <span class="nt">-1</span><span class="p">;</span> ScrollDeltaY: <span class="nt">-1</span><span class="p">;</span> AddedCount: <span class="nt">-1</span><span class="p">;</span> RemovedCount: <span class="nt">-1</span><span class="p">;</span> ParcelableData: null<span class="p">;</span> DisplayId: 0 <span class="o">]</span><span class="p">;</span> recordCount: 0
</code></pre></div></div>
<p>The plain key [DEF, 3] was there. Now, the accessibility service probably can read the input from platform authenticator. With key emulation, it can authenticate as user on screen with Passkey/Fido2 now.</p>

<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>adb shell input tap x y - switch from biometric to pin/password geometry.
adb shell input text 13337 - input pin/password.
</code></pre></div></div>

<h2 id="prevention">Prevention</h2>
<p>I tested with: <a href="https://play.google.com/store/apps/details?id=xyz.be.cake&amp;hl=en&amp;gl=US">Cake By VPBank</a> and <a href="https://play.google.com/store/apps/details?id=com.VCB&amp;hl=en&amp;gl=US">VCB Digi Bank</a>, the both are implemented correctly to prevent the service accessing password field:</p>
<ul>
  <li>In VCB Digi Bank, they dispatch the accessibility events by delegating events.</li>
  <li>In Cake By VPBank, they show dot on accessibility Text value. But in fido2 mode - by default, it calls platform authenticator, still exposed pin/password to accessibility service. The password field is no matter here.</li>
</ul>

<p>It’s very clear, the application must protect itself from accessibility service.</p>

<p>Almost banking applications I tested do not have enough protection.</p>

<p>The question is why google does not prevent accessibility obtaining the pin/password from authenticator platform. It’s system level and it introduces new risk: downgrading from biometric to pin/password.</p>

<p>Google promotes Passkey as new modern authentication method, but leaves the risk with user when platform authenticator is used. The application, indeed, must use biometric only by using <a href="https://developers.google.com/android/reference/com/google/android/gms/fido/fido2/api/common/UserVerificationMethods">UserVerificationMethod</a>. There is no other solution if you use platform authenticator until Google decides patching this issue.</p>

<p>I have another solution, using physical tokens, which authenticate via NFC/Bluetooth like: VinCSS fido2 keys or Yubikey.</p>

<h2 id="conclusion">Conclusion</h2>
<p>Some malwares still exploit this flaw to obtain pin/password to perform further privileged actions.</p>]]></content><author><name>severus</name></author><category term="Security" /><category term="privacy" /><category term="android" /><category term="accessibility" /><category term="security" /><summary type="html"><![CDATA[Android Accessibility Service Android provides accessibility service for disabilities people. This service can access all events on phone’s screen. The security hole is that it can access platform authenticator’s values: pin, password. It introduces downgrading from biometric to PIN/PASS and reduces the security of Passkey/Fido2 (builtin android support in app, not physical fido2 tokens).]]></summary></entry><entry><title type="html">How do we validate NFC ID card correctly?</title><link href="https://infosec.xyz/security/nfc-chip-validate/" rel="alternate" type="text/html" title="How do we validate NFC ID card correctly?" /><published>2023-12-28T22:15:58+00:00</published><updated>2023-12-28T22:15:58+00:00</updated><id>https://infosec.xyz/security/nfc-chip-validate</id><content type="html" xml:base="https://infosec.xyz/security/nfc-chip-validate/"><![CDATA[<h2 id="nfc-id-card---new-challenge-for-fraudsters">NFC ID Card - new challenge for fraudsters.</h2>
<p>NFC ID card is new challenge for fraudsters and banking/fintech. Based on cryptography, the data on card must be consistent.</p>

<p>NFC ID card overview:</p>
<ul>
  <li>Data is split into 16 groups (from dg1 to dg16) and SoD.</li>
  <li>SoD contains data hash from dg1-dg16 with signed message.</li>
  <li>Private key is residing in NFC chip, which can not be exported.</li>
  <li>Public key is on data, which is used to verify challenge - clone detection.</li>
  <li>Basic Access Control (BAC): the data point on Machine Readable Zone (MRZ) lines which is read by OCR to authenticate with NFC chip.</li>
  <li>Password Authenticated Connection Establishment (PACE): 6 digits code on front card ID, which read by OCR to authenticate with NFC chip.</li>
  <li>BAC and PACE protect citizen from mass scan NFC tags.</li>
</ul>

<p>Fraudsters must bypass SoD and BAC/PACE.</p>

<p>Does NFC ID Card secure onboarding process? The answer is yes and no, based on your process validation.</p>

<h2 id="the-attack-on-nfc-id-card">The attack on NFC ID Card.</h2>
<p>In my <a href="https://infosec.xyz/security/passport-nfc-extract-sod/">previous post</a>, we know the way to extract data from SoD. This poste will decribe new ways to attack NFC ID Card.</p>

<h3 id="passive-authentication-active-authentication-and-chip-authentication">Passive Authentication, Active Authentication and Chip Authentication</h3>
<p>Passive Authentication only validates SoD signed message and compares hash from dg1-16 values. If fraudsters generate new certificate and signed with this certificate, the party must validate again with Country Signing Certification Authority (CSCA). Because Document Signer Certificate (DCS) is intermediate certificate, it must be validated with CSCA or maintained with well known trusted list. This is mandatory requirement if the party validates passive authentication only.</p>

<p>Active Authentication validates authentic chip by sending some random challenge to private key and gets signed message from it. There is a problem that if the private key is DSC, fraudsters could send raw SoD data and get signed SoD. This leads to generate any valid SoD. The private key must be not DSC private key. If fraudsters are rich enough, they can create a card with their own private key, the party must validate again with well known DSC, known chip public key or CSCA.</p>

<p>Chip Authentication is mutual authentication between NFC chip and terminal. It validates both terminal and NFC chip before reading data. Both parties share their public keys and validate the signed message with trusted public key. The trusted public key is stored in NCF chip and terminal. This is the most secure way to validate data on NFC ID card.</p>

<p>If many NFC ID Cards are stolen and they are used to onboard new customers, the party must validate information with liveness detection. And server side must use vector model instead of 2D image.</p>

<p>With all information I share, not only banking/fintech must validate NFC ID card carefully, but also goverment needs to seperate the key for internal chip and the key for signing document.</p>]]></content><author><name>severus</name></author><category term="Security" /><category term="nfc" /><category term="chip" /><category term="id" /><category term="cccd" /><category term="security" /><summary type="html"><![CDATA[NFC ID Card - new challenge for fraudsters. NFC ID card is new challenge for fraudsters and banking/fintech. Based on cryptography, the data on card must be consistent.]]></summary></entry><entry><title type="html">DNS Security Part 2: Is ECH saving us from MITM?</title><link href="https://infosec.xyz/security/transparent-proxy-2/" rel="alternate" type="text/html" title="DNS Security Part 2: Is ECH saving us from MITM?" /><published>2023-11-24T14:15:58+00:00</published><updated>2023-11-24T14:15:58+00:00</updated><id>https://infosec.xyz/security/transparent-proxy-2</id><content type="html" xml:base="https://infosec.xyz/security/transparent-proxy-2/"><![CDATA[<h2 id="ech-is-final-piece-of-big-privacy-picture">ECH is final piece of big privacy picture.</h2>
<p>When we connect to website, the TLS helps us with confidence, security but no privacy. The eyes of ISP still see your target server via SNI. They could terminate the connection if target is forbidden.   <br />
ECH is new technique to save us from the eyes of ISP. It encrypts real SNI (inter SNI) when fake SNI ( outer SNI ) is public. No one could see real SNI if they don’t private ech key. A request has 2 SNI, one for real connection, one for public announcement.</p>

<p>When I read RFC, I find that ECH will help us on intercepting, filtering the connections we connect to. But I’m wrong. The RFC is still a proposal. And I have some questions, I test it and I found that some engineers implement it blindly.</p>

<h2 id="the-problem-with-ech-split-mode-is-nice-but">The problem with ECH: split mode is nice but…</h2>
<p>ECH has 2 modes: shared mode and split mode. In shared mode, backend and frontend are on same server. It doesn’t introduce any risk, because a connection must verify TLS after decrypting the ECH.<br />
In split mode, ECH is only useful for decrypting real SNI. Therefore, if we implement transparent proxy, we would decrypt ECH with 2 conditions: we control type65  (https resource record) dns request and we modify the record content with our ech public key.</p>

<h3 id="whats-transparent-proxy">What’s transparent proxy?</h3>
<p>Funny, nginx stream is one of transparent proxy, but some engineers said: no, it is not transparent proxy. What does make it transparent?<br />
Now, we talk about the transparent proxy: the connection is not modified through proxy and proxy does not terminate TLS connection. Wait, the connection is coming from proxy, not client, it’s not transparent proxy, right? No, it’s still transparent proxy. It likes NAT mode, with src address is modified and fallbacks to real client, the confidence is mutual agreement. If you need send client ip to target, some extra steps need to be setup. In this case, the geo bypass is broken.</p>

<h3 id="split-mode-and-problems">Split mode and problems</h3>
<p>Now, if someone intercepts type65 dns request and modifies ech and hint ip to their server, how could we prevent this?<br />
In split mode, the frontend verifies ECH, decrypts it and send connection to backend. It likes ECH termination, when backend must verify connection from frontend.<br />
DNS over HTTPS is required for ECH.</p>

<h2 id="support-for-sites-without-supporting-ech">Support for sites without supporting ECH</h2>
<p>In previous article, if the site supports ECH, we forward the stream to target, it’s so simple. If the sites don’t support ECH. How could we support them?<br />
The RFC said that frontend would terminate the TLS connection and act as proxy. But if we use stream module, and decrypt only ECH on stream, then stream TLS to backend, it should work. The ECH, by the way, after decrypting to real SNI, it doesn’t involveconnection.<br />
With this idea, <a href="https://github.com/sftcd">sftcd</a> project makes some modifications on <a href="https://github.com/sftcd/openssl">openssl</a> and <a href="https://github.com/sftcd/nginx">nginx</a> to support ech termination only with stream module.<br />
Build with these repo, we setup new ECH split mode. The frontend decrypts only ECH, then streams the connection to target. The configuration looks like:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>stream {
    map $ssl_preread_server_name $targetBackend {
        foo.example.com  127.0.0.1:9444;
        hidden.infosec.xyz  157.245.205.238:443;
    }

    log_format basic '$ssl_preread_server_name '
                 '$ssl_preread_alpn_protocols '
                 '$remote_addr [$time_local] '
                 '$protocol $status $bytes_sent $bytes_received '
                 '$session_time "$upstream_addr" '
                 '"$upstream_bytes_sent" "$upstream_bytes_received"';

    access_log fe/logs/access.log basic;
    ssl_preread on;
    ssl_echkeydir /root/ech-test/openssl/esnistuff/keys;
    server {
        listen  443;
        # proxy_connect_timeout 1s;
        # proxy_timeout 3s;
        #proxy_bind $remote_addr transparent;
        proxy_pass $targetBackend;

    }
}
</code></pre></div></div>

<p>To support transparent proxy, which sends client ip to backend, setup proxy_bind with extra network configuration.</p>

<p>Now, as we see in this blog, the RFC said that ECH does not support transparent proxy, it’s totally wrong. 
Real engineer implements something with RFC referrence, but RFC is changing day by day. We use it and improve it. Don’t implement it blindly, use it with your mindset. We’re engineers, we changes everything what we want. We hack it for better world.</p>]]></content><author><name>severus</name></author><category term="security" /><category term="privacy" /><category term="dns" /><category term="security" /><summary type="html"><![CDATA[ECH is final piece of big privacy picture. When we connect to website, the TLS helps us with confidence, security but no privacy. The eyes of ISP still see your target server via SNI. They could terminate the connection if target is forbidden. ECH is new technique to save us from the eyes of ISP. It encrypts real SNI (inter SNI) when fake SNI ( outer SNI ) is public. No one could see real SNI if they don’t private ech key. A request has 2 SNI, one for real connection, one for public announcement.]]></summary></entry><entry><title type="html">Retrieve kafka stream from unavailable place.</title><link href="https://infosec.xyz/security/kafka-trick/" rel="alternate" type="text/html" title="Retrieve kafka stream from unavailable place." /><published>2023-11-13T03:45:58+00:00</published><updated>2023-11-13T03:45:58+00:00</updated><id>https://infosec.xyz/security/kafka-trick</id><content type="html" xml:base="https://infosec.xyz/security/kafka-trick/"><![CDATA[<h2 id="problem">Problem</h2>
<p>I discovered some Kafka brokers. And when I consume topic, I get the error: <code class="language-plaintext highlighter-rouge">failed to get offset for topic pushgatway_send Partition 3: dial tcp 172.18.19.58:9092: i/o timeout</code> or <code class="language-plaintext highlighter-rouge">failed to get offset for topic __consumer_offsets Partition 17: dial tcp: lookup broker on 127.0.0.1:53: no such host</code>.
How can we retrieve kafka stream?</p>

<h2 id="again-dns-and-network">Again, dns and network</h2>
<p>Kafka broker handles all requests from clients to read and write events. The topic may be on different partition.
These above errors show that <code class="language-plaintext highlighter-rouge">no dns and no route to internal broker</code>.</p>

<p>Now, as network engineer, what’s in your mind?<br />
DNS is alias of ip address. We remap DNS to exact ip show <code class="language-plaintext highlighter-rouge">no such host</code>.</p>

<p>How’s about i/o timeout? redirect the traffic to this ip with your state full firewall. Because broker may have multiple network interfaces, and it exposed 1 interface, redirect from public interface then it should redirect to internal interface.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>iptables <span class="nt">-t</span> nat <span class="nt">-A</span> POSTROUTING <span class="nt">-p</span> tcp <span class="nt">--dport</span> 9092 <span class="nt">-j</span> MASQUERADE
iptables <span class="nt">-t</span> nat <span class="nt">-A</span> OUTPUT <span class="nt">-p</span> tcp <span class="nt">--dport</span> 9092 <span class="nt">-j</span> DNAT <span class="nt">--to-destination</span> <span class="nv">$kafka_public_ip</span>:<span class="nv">$port</span>
</code></pre></div></div>

<p>This code should work, except the host is <code class="language-plaintext highlighter-rouge">127.*.*.*</code>. Kernel prevents reroute localnet by default. Then we need other trick</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sysctl <span class="nt">-w</span> net.ipv4.conf.all.route_localnet<span class="o">=</span>1
</code></pre></div></div>
<p>Then if the partition is on broker, data should be retrieved.</p>]]></content><author><name>severus</name></author><category term="security" /><category term="kafka" /><category term="configuration" /><category term="security" /><summary type="html"><![CDATA[Problem I discovered some Kafka brokers. And when I consume topic, I get the error: failed to get offset for topic pushgatway_send Partition 3: dial tcp 172.18.19.58:9092: i/o timeout or failed to get offset for topic __consumer_offsets Partition 17: dial tcp: lookup broker on 127.0.0.1:53: no such host. How can we retrieve kafka stream?]]></summary></entry><entry><title type="html">Extract passport NFC’s SoD certificate</title><link href="https://infosec.xyz/security/passport-nfc-extract-sod/" rel="alternate" type="text/html" title="Extract passport NFC’s SoD certificate" /><published>2023-10-18T03:45:58+00:00</published><updated>2023-10-18T03:45:58+00:00</updated><id>https://infosec.xyz/security/passport-nfc-extract-sod</id><content type="html" xml:base="https://infosec.xyz/security/passport-nfc-extract-sod/"><![CDATA[<p>NFC data is followed ICAO’s <a href="https://www.icao.int/publications/documents/9303_p10_cons_en.pdf">specification</a>.</p>

<p>We must verify the Security Object Document (SoD), it contains signature, data and certificate of Document Signer (DS).</p>

<p>Wait, what’s Document Signer Certificate (DSC)? DSC is intermediate certificate, which is signed by Country Signing Certification Authority (CSCA). DSC is in SoD, CSCA should be public, so everyone can verify the SoD independently.</p>

<p>Look at SoD, we have someway to inspect it.</p>

<p>Extract SoD, we have base64 data, then convert it to der format:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cat </span>sod.txt| <span class="nb">base64</span> <span class="nt">-d</span> <span class="o">&gt;</span> sod.der
</code></pre></div></div>

<p>strip out SoD header, we have pkcs7 format:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl asn1parse <span class="nt">-inform</span> der <span class="nt">-in</span> sod.der <span class="nt">-strparse</span> 4 <span class="nt">-noout</span> <span class="nt">-out</span> sod.pkcs7
</code></pre></div></div>

<p>with sod.pkcs7 we have all data group’s hashes.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl cms <span class="nt">-inform</span> der <span class="nt">-noverify</span> <span class="nt">-verify</span> <span class="nt">-in</span> sod.pkcs7 <span class="nt">-out</span> sod.message
openssl asn1parse <span class="nt">-inform</span> der <span class="nt">-in</span> sod.message
</code></pre></div></div>

<p>Extract the certificate from SoD:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl pkcs7 <span class="nt">-inform</span> der <span class="nt">-print_certs</span> <span class="nt">-in</span> sod.pkcs7
</code></pre></div></div>

<p>Inspect certificate from SoD:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl pkcs7 <span class="nt">-inform</span> der <span class="nt">-print_certs</span> <span class="nt">-in</span> sod.pkcs7 | openssl x509 <span class="nt">-noout</span> <span class="nt">-text</span>
</code></pre></div></div>

<p>We know the CSCA location from DSC’s content.</p>

<p>If we have CSCA, we can verify SoD from our end independently:</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>openssl cms <span class="nt">-inform</span> der  <span class="nt">-verify</span> <span class="nt">-certfile</span> CSCA.cert <span class="nt">-in</span> sod.pkcs7 <span class="nt">-noout</span>
</code></pre></div></div>

<p>If we have CSCA - which should be public by default, we will validate without problem on our side.</p>]]></content><author><name>severus</name></author><category term="security" /><category term="passport" /><category term="nfc" /><category term="SoD" /><category term="extraction" /><summary type="html"><![CDATA[NFC data is followed ICAO’s specification.]]></summary></entry><entry><title type="html">Google BeyondCorp Walkthrough</title><link href="https://infosec.xyz/security/google-beyondcorp/" rel="alternate" type="text/html" title="Google BeyondCorp Walkthrough" /><published>2023-10-09T03:45:58+00:00</published><updated>2023-10-09T03:45:58+00:00</updated><id>https://infosec.xyz/security/google-beyondcorp</id><content type="html" xml:base="https://infosec.xyz/security/google-beyondcorp/"><![CDATA[<h2 id="zerotrust-is-just-a-access-context-management">ZeroTrust is just a access context management</h2>
<p>Some years ago, I heard that zerotrust would become the future of security. Nowaday, I see zerotrust in every security product advertisment.
From my perspective, the architecture of zerotrust is just combining multiple way to identify the user at specific step. It reduces the risk by: defining the context: where user is coming from, which should be validated from request, privilege should be granted on this context or not…</p>

<p>It is context access managament, for simply understanding.</p>

<h2 id="beyondcorp-and-the-incomplete-trust">BeyondCorp and the incomplete trust.</h2>
<p>BeyondCorp Enterprise (BCE) provides the Identity-Aware Proxy (IAP) and Access Context Manager (ACM). The IAP replies on ACM to validate user before accessing the resoures.</p>

<h3 id="the-design-of-architecture">The design of architecture</h3>
<p>The BCE is powered by Chrome Browser to delivery the policy, enforce workflows.</p>

<p>Let digging it in deep:<br />
Chrome has extension: Endpoint Verification and Chrome’s sync is builtin. 
When user logged in Chrome’s sync, a set of policies are pushed to user from ACM included: disable proxy on chrome, some enforcements,…
Enpoint Verification has run independently of Chrome’s sync.</p>

<h3 id="nothing-is-connected-with-each-other">Nothing is connected with each other</h3>
<p>User must sign in chrome’s sync to obtain the policy. Endpoint verification doesnot use chrome’s sync. Then no policy is distributed to users. It leads to all problems below.</p>

<h4 id="cloning-device-with-endpoint-verification">Cloning Device with Endpoint Verification</h4>
<p>When admin uploads device’s infomation to ACM, the data is static. Microsoft Intune is example here - will collect and validate the compliance  of device. Google syncs device’s status and sends to ACM.</p>

<p>Endpoint verification collects: encrypted disk status, mac address, serial number, device model, os version and sends to Google. It will compare with existed device’s information then assign context to a resource.</p>

<p>ACM has 3 levels, when you impersonate device’s infomation, no difference between them.</p>

<h4 id="endpoint-verification-can-work-without-chromes-sync">Endpoint verification can work without Chrome’s sync</h4>
<p>The flow to avoid syncing policies:<br />
users installed extension on chromium based browsers =&gt; login to extension not chrome’s sync feature =&gt; wait for device’s info synced completely =&gt; IAP validates submission then decides access context.</p>

<p>Look at http requests, I found 2 endpoints allowing me to impersonate device with those values above.</p>

<p>This <a href="https://secureconnect-pa.clients6.google.com/v1:enrollDevice?key=AIzaSyAJhvxfD777039sTg-pLourELbcDu0nDc4">enroll endpoint</a> allows user to register device.</p>

<p>This <a href="https://secureconnect-pa.clients6.google.com/v1:reportDeviceState?key=AIzaSyAJhvxfD777039sTg-pLourELbcDu0nDc4">reportDeviceState</a> report device’s infomation per 15 minutes.</p>

<p>The body is encrypted with key which is rotated every month.</p>

<p>The magic here, when obtain the valid body request, anyone of corporation can register as owner this device and allowed to access internal resources.</p>

<h4 id="start-connection-is-just-openvpn">Start connection is just OpenVPN</h4>

<p>Enpoint Verification has another feature: start connection which is based on OpenVPN, only available on Windows and MacOS.</p>

<p>On Mac/Windows, Chrome uses OpenVPN to acces internal resources. On Linux, it creates ec384 key pair at <code class="language-plaintext highlighter-rouge">$XDG_HOME/google/Endpoint Verification/certs/</code>, but I don’t see it is used anywhere. Extension’s code shows that it’s used as client authentication.</p>

<p>BCE Admin Helper on Mac/Windows uses OpenVPN and creates OpenVPN Management Interface to operate with Endpoint Extension.</p>

<p>The flow of OpenVPN: <br />
Now, it uses Chrome’s sync here, the refresh token is obtained from Chrome’s sync and send 2 different requests: which obtains auth for issuetoken.google.com and 1 token for authenticating with OpenVPN.</p>

<p>Endpoint verification sends username and 1 time password to BCE Admin Helper through socket. The password is very short TTL.</p>

<h2 id="conclusion">Conclusion</h2>
<p>As I see, I can obtain the body of register/report device state and relay to any device. In the dashboard, admin only see my authorized device. Intune only helps check compliance, the data is static even it is encrypted. No way to check the request is coming from authorized devices.</p>

<p>BCE is not perfect as I know, we cannot rely on single factor: Endpoint verification. Look at the http requests, more problem I discovered when attacker can obtain device info via assets management team and 1 account was compromise. Nothing’s secure here. Corporation must use Role Based Access Control, IAP is only additional enhancement.</p>

<p>I reported to Google and they acknowledged this problem.
In the future, I think I would like to chain some problem to access something.</p>]]></content><author><name>severus</name></author><category term="security" /><category term="google" /><category term="IAP" /><category term="security" /><summary type="html"><![CDATA[ZeroTrust is just a access context management Some years ago, I heard that zerotrust would become the future of security. Nowaday, I see zerotrust in every security product advertisment. From my perspective, the architecture of zerotrust is just combining multiple way to identify the user at specific step. It reduces the risk by: defining the context: where user is coming from, which should be validated from request, privilege should be granted on this context or not…]]></summary></entry><entry><title type="html">TLS fingerprint and mobile security</title><link href="https://infosec.xyz/security/mobile-ja3/" rel="alternate" type="text/html" title="TLS fingerprint and mobile security" /><published>2023-08-02T14:45:58+00:00</published><updated>2023-08-02T14:45:58+00:00</updated><id>https://infosec.xyz/security/mobile-ja3</id><content type="html" xml:base="https://infosec.xyz/security/mobile-ja3/"><![CDATA[<h2 id="the-use-case">The use case</h2>
<p>Mobile applications are replacing the traditional web applications. Some techniques are developed to identify the requests are coming from official application - which they own and not from emulators.</p>

<p>We have some enterprise’s features as Appcheck from Google and DeviceCheck from Apple.</p>

<p>These features use cryptography to validate whether requests are coming from authorized devices and applications. Despite the complexity of system design, we must revalidate messages from Google and Apple again before proceeding with any further action.</p>

<h2 id="simple-solution-the-ja3---simple-tls-clients-fingerprint">Simple solution: The JA3 - Simple TLS client’s fingerprint</h2>
<p>JA3 is developed by Salesforce. It calculates the order of Client Hello’s fields (TLSVersion,Ciphers,Extensions,EllipticCurves,EllipticCurvePointFormats), same client and TLS library should return the same JA3. 
The value depends on TLS library and client version supporting TLS cipher, extension’s order. if we own the implementation in our app, the value should be fixed for whitelisting purpose.</p>

<p>The implementation must be based on TLS initiation, where the application constructs the Client Hello’s fields. However if the Client Hello’s order extensions are the same, how do we check if it’s authentic? Google uses GREASE for another purpose, and we can leverage this for our purpose by adding a specific GREASE extension with our chosen ciphersuite and ALPN. It requires rewriting the JA3’s calculation, as it defaults to ignoring GREASE’s values and strictly follows the extension’s order from server side.</p>

<p>Since the TLS handshake is invisible to our users, it should not be relayed from malious actors. Of course, it’s weaker than Appcheck, which involves two-way validation through signed requests and platform providers like Google/Apple. Nevertheless, this is the easiest way to implement and explore some new ideas.</p>]]></content><author><name>severus</name></author><category term="security" /><category term="ja3" /><category term="mobile" /><category term="security" /><summary type="html"><![CDATA[The use case Mobile applications are replacing the traditional web applications. Some techniques are developed to identify the requests are coming from official application - which they own and not from emulators.]]></summary></entry></feed>