<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vihanga Nimsara</title>
    <description>The latest articles on DEV Community by Vihanga Nimsara (@vihanga_nimsara_2004).</description>
    <link>https://dev.to/vihanga_nimsara_2004</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3781959%2F98d45580-41b1-4a46-8988-9191b88aa0ad.jpg</url>
      <title>DEV Community: Vihanga Nimsara</title>
      <link>https://dev.to/vihanga_nimsara_2004</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vihanga_nimsara_2004"/>
    <language>en</language>
    <item>
      <title>I Entered a Fake CVV — Here’s Why the Bank Immediately Rejected It</title>
      <dc:creator>Vihanga Nimsara</dc:creator>
      <pubDate>Fri, 20 Feb 2026 10:35:37 +0000</pubDate>
      <link>https://dev.to/vihanga_nimsara_2004/i-entered-a-fake-cvv-heres-why-the-bank-immediately-rejected-it-4b1j</link>
      <guid>https://dev.to/vihanga_nimsara_2004/i-entered-a-fake-cvv-heres-why-the-bank-immediately-rejected-it-4b1j</guid>
      <description>&lt;p&gt;**Recently, I ran into something interesting while adding a credit card to an online payment system.&lt;/p&gt;

&lt;p&gt;I wasn’t making a purchase — just saving the card.&lt;/p&gt;

&lt;p&gt;Out of curiosity, I entered a fake CVV.&lt;/p&gt;

&lt;p&gt;The card was immediately declined.**&lt;/p&gt;

&lt;p&gt;That raised an important technical question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Is CVV really verified even when no payment is made?
- How is CVV generated by banks?
- How does CVV verification actually work?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This article breaks down the technical process of CVV generation and validation, including the cryptographic mechanisms used by banks and card networks like Visa and Mastercard.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is CVV in Payment Systems?
&lt;/h2&gt;

&lt;p&gt;As Undergraduate I thought CVV as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“Just a 3-digit security number on the back of the card.”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Technically, that’s not accurate.&lt;/p&gt;

&lt;p&gt;CVV (Card Verification Value) is a cryptographic value generated by the issuing bank using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PAN (Primary Account Number – card number)&lt;/li&gt;
&lt;li&gt;Expiry date&lt;/li&gt;
&lt;li&gt;Service code&lt;/li&gt;
&lt;li&gt;A secret cryptographic key (known only to the bank)&lt;/li&gt;
&lt;li&gt;DES or 3DES encryption&lt;/li&gt;
&lt;li&gt;A Hardware Security Module (HSM)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not random.&lt;br&gt;
It is not guessable.&lt;br&gt;
It is not stored by merchants.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why It Failed Even Without a Purchase
&lt;/h2&gt;

&lt;p&gt;In my scenario I assumed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“If I’m not making a payment, the CVV shouldn’t matter.”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But here’s what actually happens.&lt;/p&gt;

&lt;p&gt;When you “add a card,” most systems perform one of the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Zero-amount authorization&lt;/li&gt;
&lt;li&gt; Small temporary authorization (refundable)&lt;/li&gt;
&lt;li&gt; Network-level card validation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So even if you are not paying, the system still:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sends card details to the payment gateway&lt;/li&gt;
&lt;li&gt;Gateway routes request via the card network (e.g., Visa / Mastercard)&lt;/li&gt;
&lt;li&gt;The issuing bank validates the CVV&lt;/li&gt;
&lt;li&gt;If CVV does not match → Declined&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So yes — CVV is verified even when you’re “just adding” a card.&lt;/p&gt;

&lt;h2&gt;
  
  
  How CVV Is Generated (Technical Deep Dive)
&lt;/h2&gt;

&lt;p&gt;Let’s go deeper.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Data Preparation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The bank combines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PAN (Card Number)
Expiry Date (YYMM)
Service Code (e.g., 101)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4539148803436467
2708
101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Concatenated into one data block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Encryption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The bank encrypts this data using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DES or 3DES algorithm&lt;/li&gt;
&lt;li&gt;A secret key stored inside an HSM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The secret key never leaves the bank’s secure infrastructure.&lt;/p&gt;

&lt;p&gt;Even if you know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The card number&lt;/li&gt;
&lt;li&gt;Expiry date&lt;/li&gt;
&lt;li&gt;Service code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without the secret key, you cannot compute the correct CVV.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Extract CVV Digits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After encryption:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The output is a long numeric/hexadecimal value&lt;/li&gt;
&lt;li&gt;The bank extracts specific decimal digits&lt;/li&gt;
&lt;li&gt;Typically, the first 3 digits become the CVV&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example output after encryption:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;839275192837465
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take first 3 digits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;839 → CVV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s the number printed on your card.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Technical Flow Diagram
&lt;/h2&gt;

&lt;p&gt;Here’s the simplified flow when you enter your card online:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User
  |
  |  Enter Card + CVV
  v
Merchant Website
  |
  |  Encrypted Request
  v
Payment Gateway
  |
  |  Routed via Network
  v
Card Network (Visa / Mastercard)
  |
  v
Issuing Bank
  |
  |  Recalculate CVV using:
  |  - PAN
  |  - Expiry
  |  - Service Code
  |  - Secret Key (HSM)
  |
  |  Compare with entered CVV
  |
  +--&amp;gt; Match → Approve
  |
  +--&amp;gt; Mismatch → Decline
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important:&lt;/p&gt;

&lt;p&gt;The merchant never calculates CVV.&lt;br&gt;
The payment gateway never generates CVV.&lt;br&gt;
Only the issuing bank can validate it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Merchants Cannot Store CVV
&lt;/h2&gt;

&lt;p&gt;Under PCI-DSS compliance rules defined by PCI Security Standards Council:&lt;/p&gt;

&lt;p&gt;Merchants are strictly prohibited from storing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CVV&lt;/li&gt;
&lt;li&gt;PIN&lt;/li&gt;
&lt;li&gt;Full magnetic stripe data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why you must re-enter CVV even when a card is saved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can CVV Be Brute-Forced?
&lt;/h2&gt;

&lt;p&gt;Technically, there are only 1000 combinations (000–999).&lt;/p&gt;

&lt;p&gt;But in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Banks apply rate limiting&lt;/li&gt;
&lt;li&gt;Fraud detection systems monitor attempts&lt;/li&gt;
&lt;li&gt;Card networks flag suspicious activity&lt;/li&gt;
&lt;li&gt;Multiple failed attempts block transactions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So brute-force attacks are effectively prevented.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;My fake CVV failed because:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The system performed a real authorization check&lt;/li&gt;
&lt;li&gt;The issuing bank recalculated the CVV&lt;/li&gt;
&lt;li&gt;The values did not match&lt;/li&gt;
&lt;li&gt;The bank declined the request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What looks like a simple 3-digit number is actually part of a secure cryptographic architecture involving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symmetric encryption&lt;/li&gt;
&lt;li&gt;Hardware Security Modules&lt;/li&gt;
&lt;li&gt;Network-level routing&lt;/li&gt;
&lt;li&gt;Fraud detection systems&lt;/li&gt;
&lt;li&gt;PCI compliance frameworks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes a simple experiment reveals the complexity of global payment infrastructure.&lt;/p&gt;

</description>
      <category>security</category>
      <category>fintech</category>
      <category>cryptography</category>
      <category>payments</category>
    </item>
  </channel>
</rss>
