41. Session Hijacking – Tokens, Cookies and Defence
41.8 Defence Hardening Checklist
SME / lab checklist (print for Rani):
- HTTPS everywhere on auth and cookies; HSTS
- Cookie flags: Secure, HttpOnly, SameSite=Lax (or Strict where UX allows)
- Regenerate session ID on login and privilege elevation
- Short idle / absolute TTL; "remember me" = separate hardened design
- Logout destroys server-side session, not only browser cookie clear
- MFA for admin / payout / email-change
- CSRF tokens on state-changing requests
- XSS hygiene + CSP on app pages
- Avoid SID in URL; avoid tokens in localStorage for high-value sessions when cookie pattern fits
- Monitor concurrent sessions; admin "kill sessions" button
- WAF rules for common session abuse patterns (support, not sole control)
- Framework updates – session libs have CVEs historically
<?php
// OWN lab PHP sketch – after password verified (illustrative)
session_start();
// ... verify password against DB (prepared statements) ...
session_regenerate_id(true);
$_SESSION['user'] = 'rani';
$_SESSION['login_at'] = time();
// php.ini / ini_set ideas for lab:
// session.cookie_httponly = 1
// session.cookie_secure = 1 // needs HTTPS
// session.cookie_samesite = Lax
?>
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
| Hopes logout only cleared client cookie | Server-side session destroy + new ID |
| Uses week-old stolen cookie | Short TTL + idle timeout + absolute timeout |
| Targets admin without MFA | MFA + regenerate + alert on admin UA/IP change |
Ravindra Bagale's Tip
Make the checklist your wallpaper – but prove it with curl before/after in the lab. A paper policy without regenerate = false comfort. Interview: walk through 5 controls without reading your notes.
Ravindra Bagale's Tip – मराठी
Checklist wallpaper बनवा – पण lab मध्ये curl before/after ने prove करा. Regenerate शिवाय paper policy = खोटे समाधान. Interview: notes न वाचता 5 controls सांगा.
Ravindra Bagale's Tip – हिंदी
Checklist को wallpaper बनाओ – पर lab में curl before/after से prove करो. Regenerate के बिना paper policy = झूठी तसल्ली. Interview: notes पढ़े बिना 5 controls बताओ.
Practice task
Score Sahyadri Traders current fictional portal 0–12 on the checklist. Pick worst 3 gaps; write owner email in professional English proposing fix order (HTTPS → flags → regenerate → TTL → MFA).
Extended teaching notes
Why this lesson matters
Web flaws stay in the OWASP Top 10 because real apps still ship them. Your job is not to collect tool screenshots. It is to prevent and fix the class of bug on systems you own.
Apply the fix across stacks
Same class of bug, same idea in every language.
Java / Spring Boot
Parameterise queries, encode output, CSRF tokens, limited Actuator, dependency scanning.
ASP.NET Core
EF Core / parameterised SQL, Razor encoding, HTTPS, Data Protection.
Node.js / Express
helmet, parameterised SQL, npm audit, avoid eval and shell concat.
Python / Django / Flask / FastAPI
ORM, autoescape, pip-audit, Bandit; never shell=True with user input.
PHP / Laravel
PDO/Eloquent, Blade escaping, composer audit.
Go / Ruby
database/sql placeholders / ActiveRecord; html/template / ERB escaping; govulncheck / Brakeman.
nginx / Apache / Tomcat
Hide versions, TLS, security headers, least-open ports.
MySQL / PostgreSQL / MongoDB / Redis
Private networks, auth on, least-privilege users, no 0.0.0.0/0.
AWS / Azure / GCP
Roles not long-lived keys, private data stores, cloud audit logs on.
Real examples
Global: injection and XSS still appear in breach reports and bug bounties every year. Indian company (sample): a Bengaluru SaaS team maps each OWASP item to a CI check or a code-review question so new code cannot silently reintroduce it.
Mini case study
Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.
Defender's worksheet (do this today)
- Write the lesson title, date and the exact lab target you are allowed to use.
- List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
- Run one safe check from the lesson on a lab system only. Paste the command and output.
- Write a two-sentence fix you would give a teammate.
- Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.
Indian workplace (sample data)
Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).
Global practice
Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.
Everyday analogy
Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.
Key terms
- Control: a safeguard (patch, config, process, detection).
- Finding: a weakness backed by evidence.
- Remediation: the fix plus how you verified it.
- Scope: systems you have written permission to touch.
- Least privilege: only the access the task needs.
- Defence in depth: several layers so one failure does not end the story.
Common mistakes
- Skipping written permission "just for a quick scan".
- Practising on hostel, office or public targets without authorisation.
- Collecting tool output without writing the fix.
- Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
- Publishing screenshots that contain secrets, cookies or internal hostnames.
Recap
- Evidence, fix, owner, date.
- Own lab only.
- Fix > spectacle.
Real incident: Onamae.com Desktop Cloud (Japan) – stolen trading logins used for unauthorized trades; changing the password was not enough (Oct 2026)
1. What happened
In this lesson's checklist you saw two lines: "Logout destroys the server-side session" and "admin kill sessions button". This real case shows why those lines matter. Here, a new password alone did not lock the attacker out.
- Onamae.com Desktop Cloud is a Windows cloud server (VPS) service from GMO Internet in Japan. Many people used it to run trading tools such as MT4/MT5 all day and night for FX and stock trading.
- On 20 October 2026, GMO confirmed that a third party had installed malicious programs on some customer servers. A customer question on 19 October started the investigation.
- From 21 October, GMO shut down the servers of all plans. Up to 26,739 servers may be affected (this is the number that may be affected, not confirmed cases).
- On 24 October, GMO confirmed that its system had security weaknesses, that customer information was taken out, and that some customers saw trades in their trading accounts that they did not make.
- The attacker asked GMO for money. It threatened to keep placing bad orders in customer accounts at more than 70 securities and FX companies, and to publish data. GMO refused to pay and gave the evidence to the police.
- GMO said it will not restart the old system. It will pay every current customer 5,000 yen and pay back realized losses from unauthorized trades.
2. How the hack happened (public reporting only – high-level)
- Customers rented a Windows server and saved their trading account logins inside trading tools on that server.
- The attacker got into the service's environment through security weaknesses in GMO's system. GMO has not yet published the exact entry route; an outside security firm is still investigating.
- The attacker installed malicious programs on customer servers.
- It took information stored on the servers, including saved trading logins.
- It used that access to place orders in customers' trading accounts.
- GMO warned that even after a password change, an already logged-in session could stay active for some time on some brokers' servers. So the attacker might keep trading. GMO asked customers to disconnect all sessions, and asked brokers to force-close all sessions coming from the service.
3. How to stop it / defend (this lesson: the session defence checklist)
Why: a password protects the next login. It does not end a session that is already open. So "change password" and "kill all sessions" must always go together.
If you build a login system (for example, a broker or banking app):
- On password change or reset, delete all of that user's sessions on the server, not only the current browser cookie. Example in PHP: keep a number like
session_versionin the users table, add 1 on password change, and on every request compare it with the number saved in$_SESSION; if they differ, callsession_destroy(). - Give users a "Log out of all devices" button, and give your support team an admin "kill sessions" button.
- Ask for MFA again before money actions (a trade, a withdrawal, a new bank account), even inside a logged-in session.
- Use a short idle timeout and an absolute timeout, so old sessions die on their own.
- Alert the user when a new device or a new network starts a session, and show a list of active sessions.
If you run servers for other people (a cloud or hosting provider):
- Keep your management systems separate from customer servers, so one break-in cannot reach every customer.
- Watch for new programs appearing on many customer servers at once, and be ready to shut down fast (GMO started shutting servers within about a day of confirming the malware).
4. How to take care so it won't happen again (checklist)
- [ ] After any account scare: change the password from a clean device, then log out of all sessions, then check the history.
- [ ] Turn on two-step verification on trading, bank and email accounts.
- [ ] Do not keep passwords as plain text or saved logins on a shared or rented server. Use a password manager and a different password for each service.
- [ ] Builders: test it yourself – log in on two browsers, change the password in one, and check that the other one is logged out.
- [ ] Builders: require fresh MFA for every money action.
- [ ] Never pay a blackmailer. Paying does not guarantee the stolen data is deleted. Report it to the police.
- [ ] After an incident, expect fake "refund" or "compensation" emails. Never share a password or PIN because of such a message.
Source: GMO Internet, "Notice and Apology Regarding Unauthorized Access to Onamae.com Desktop Cloud" – Third Report (23 October 2026) and Fourth Report (24 October 2026); GMO Internet, "Renewed Request to Customers Using Onamae.com Desktop Cloud" – Fifth Report (24 October 2026); BleepingComputer, "Japan's Onamae Desktop Cloud hacked, up to 27,000 servers affected", 21 October 2026.
1. काय झालं
या lesson च्या checklist मध्ये तुम्ही दोन lines पाहिल्या: "Logout destroys the server-side session" आणि "admin kill sessions button". या lines किती महत्त्वाच्या आहेत ते ही खरी घटना दाखवते. इथे फक्त नवीन password ठेवून attacker बाहेर गेला नाही.
- Onamae.com Desktop Cloud ही जपानमधल्या GMO Internet ची Windows cloud server (VPS) service आहे. FX आणि share trading साठी MT4/MT5 सारखे trading tools दिवस-रात्र चालवायला बरेच लोक ती वापरत होते.
- 20 ऑक्टोबर 2026 ला GMO ने confirm केलं की कोणीतरी बाहेरच्या व्यक्तीने काही customer servers वर malicious programs install केले. 19 ऑक्टोबरला एका customer च्या प्रश्नामुळे investigation सुरू झालं.
- 21 ऑक्टोबर पासून GMO ने सगळ्या plans चे servers बंद केले. 26,739 पर्यंत servers affected असू शकतात (हा "असू शकतात" असा आकडा आहे, confirm झालेल्या cases चा नाही).
- 24 ऑक्टोबर ला GMO ने confirm केलं की त्यांच्या system मध्ये security weaknesses होत्या, customer information बाहेर नेली गेली, आणि काही customers च्या trading accounts मध्ये त्यांनी न केलेले trades दिसले.
- Attacker ने GMO कडे पैसे मागितले. त्याने धमकी दिली की 70 पेक्षा जास्त securities आणि FX companies मधल्या customer accounts मध्ये तो चुकीच्या orders टाकत राहील, आणि data publish करेल. GMO ने पैसे द्यायला नकार दिला आणि पुरावे police ला दिले.
- GMO ने सांगितलं की ते जुनी system परत सुरू करणार नाहीत. ते प्रत्येक current customer ला 5,000 yen देतील, आणि unauthorized trades मुळे झालेलं प्रत्यक्ष नुकसान भरून देतील.
2. Hack कसा झाला (फक्त public reporting – high-level)
- Customers नी Windows server भाड्याने घेतला आणि त्यावरच्या trading tools मध्ये trading account चे login save करून ठेवले.
- Attacker GMO च्या system मधल्या security weaknesses मधून service च्या environment मध्ये घुसला. नेमका entry route GMO ने अजून publish केलेला नाही; बाहेरची security firm अजून investigation करत आहे.
- Attacker ने customer servers वर malicious programs install केले.
- त्याने servers वर ठेवलेली information नेली, त्यात save केलेले trading logins पण होते.
- त्या access ने त्याने customers च्या trading accounts मध्ये orders टाकल्या.
- GMO ने warning दिली की काही brokers च्या servers वर password बदलल्यानंतरही, आधीपासून logged-in असलेला session काही वेळ चालू राहू शकतो. म्हणजे attacker trading करत राहू शकतो. म्हणून GMO ने customers ना सगळे sessions disconnect करायला सांगितलं, आणि brokers ना या service मधून येणारे सगळे sessions force-close करायला सांगितलं.
3. हे कसं थांबवायचं / defend कसं करायचं (हा lesson: session defence checklist)
का: password पुढच्या login ला protect करतो. तो आधीच उघडा असलेला session बंद करत नाही. म्हणून "password बदला" आणि "सगळे sessions kill करा" हे नेहमी एकत्रच करायचं.
तुम्ही login system बनवत असाल तर (उदा. broker किंवा banking app):
- Password change किंवा reset झाल्यावर server वरचे त्या user चे सगळे sessions delete करा, फक्त current browser ची cookie नाही. PHP मधलं उदाहरण: users table मध्ये
session_versionसारखा एक number ठेवा, password बदलला की त्यात 1 add करा, आणि प्रत्येक request वर तो$_SESSIONमध्ये save केलेल्या number शी compare करा; वेगळा असेल तरsession_destroy()call करा. - Users ना "Log out of all devices" button द्या, आणि support team ला admin "kill sessions" button द्या.
- पैशांच्या actions आधी परत MFA मागा (trade, withdrawal, नवीन bank account), logged-in session मध्ये असलं तरी.
- छोटा idle timeout आणि absolute timeout ठेवा, म्हणजे जुने sessions आपोआप संपतील.
- नवीन device किंवा नवीन network वरून session सुरू झाला की user ला alert पाठवा, आणि active sessions ची list दाखवा.
तुम्ही दुसऱ्यांसाठी servers चालवत असाल तर (cloud किंवा hosting provider):
- तुमच्या management systems customer servers पासून वेगळ्या ठेवा, म्हणजे एका break-in मध्ये सगळ्या customers पर्यंत पोहोचता येणार नाही.
- एकाच वेळी अनेक customer servers वर नवीन programs दिसले तर लक्ष ठेवा, आणि लगेच बंद करायची तयारी ठेवा (malware confirm झाल्यावर साधारण एका दिवसात GMO ने servers बंद करायला सुरुवात केली).
4. हे परत होऊ नये म्हणून काय काळजी घ्यायची (checklist)
- [ ] Account बद्दल काही शंका आली तर: clean device वरून password बदला, मग सगळ्या sessions मधून logout करा, मग history check करा.
- [ ] Trading, bank आणि email accounts वर two-step verification चालू करा.
- [ ] Shared किंवा भाड्याच्या server वर passwords plain text मध्ये किंवा saved logins म्हणून ठेवू नका. Password manager वापरा आणि प्रत्येक service साठी वेगळा password ठेवा.
- [ ] Builders: स्वतः test करा – दोन browsers मध्ये login करा, एकात password बदला, आणि दुसरा logout झाला का ते check करा.
- [ ] Builders: प्रत्येक पैशांच्या action साठी fresh MFA मागा.
- [ ] Blackmailer ला कधीही पैसे देऊ नका. पैसे दिले तरी चोरलेला data delete होईल याची guarantee नाही. Police कडे report करा.
- [ ] Incident नंतर खोटे "refund" किंवा "compensation" emails येतील असं समजून चला. अशा message मुळे password किंवा PIN कधीही share करू नका.
स्रोत: GMO Internet, "Notice and Apology Regarding Unauthorized Access to Onamae.com Desktop Cloud" – Third Report (23 ऑक्टोबर 2026) and Fourth Report (24 ऑक्टोबर 2026); GMO Internet, "Renewed Request to Customers Using Onamae.com Desktop Cloud" – Fifth Report (24 ऑक्टोबर 2026); BleepingComputer, "Japan's Onamae Desktop Cloud hacked, up to 27,000 servers affected", 21 ऑक्टोबर 2026.
1. क्या हुआ
इस lesson की checklist में आपने दो lines देखीं: "Logout destroys the server-side session" और "admin kill sessions button". ये lines कितनी ज़रूरी हैं, यह असली घटना दिखाती है. यहाँ सिर्फ़ नया password रखने से attacker बाहर नहीं हुआ.
- Onamae.com Desktop Cloud जापान की GMO Internet की Windows cloud server (VPS) service है. FX और share trading के लिए MT4/MT5 जैसे trading tools दिन-रात चलाने के लिए बहुत लोग इसे इस्तेमाल करते थे.
- 20 अक्टूबर 2026 को GMO ने confirm किया कि किसी बाहरी व्यक्ति ने कुछ customer servers पर malicious programs install किए. 19 अक्टूबर को एक customer के सवाल से investigation शुरू हुई.
- 21 अक्टूबर से GMO ने सभी plans के servers बंद कर दिए. 26,739 तक servers affected हो सकते हैं (यह "हो सकते हैं" वाला आँकड़ा है, confirm हुए cases का नहीं).
- 24 अक्टूबर को GMO ने confirm किया कि उनके system में security weaknesses थीं, customer information बाहर ले जाई गई, और कुछ customers के trading accounts में ऐसे trades दिखे जो उन्होंने नहीं किए.
- Attacker ने GMO से पैसे माँगे. उसने धमकी दी कि वह 70 से ज़्यादा securities और FX companies के customer accounts में गलत orders डालता रहेगा, और data publish करेगा. GMO ने पैसे देने से मना कर दिया और सबूत police को दिए.
- GMO ने कहा कि वह पुराना system दोबारा शुरू नहीं करेगी. वह हर current customer को 5,000 yen देगी, और unauthorized trades से हुआ असली नुकसान भर देगी.
2. Hack कैसे हुआ (सिर्फ़ public reporting – high-level)
- Customers ने Windows server किराए पर लिया और उस पर trading tools में trading account के login save करके रखे.
- Attacker GMO के system की security weaknesses से service के environment में घुसा. सही entry route GMO ने अभी publish नहीं किया है; बाहरी security firm अभी investigation कर रही है.
- Attacker ने customer servers पर malicious programs install किए.
- उसने servers पर रखी information ले ली, जिसमें save किए हुए trading logins भी थे.
- उस access से उसने customers के trading accounts में orders डाले.
- GMO ने warning दी कि कुछ brokers के servers पर password बदलने के बाद भी, पहले से logged-in session कुछ समय तक चालू रह सकता है. यानी attacker trading करता रह सकता है. इसलिए GMO ने customers से सारे sessions disconnect करने को कहा, और brokers से इस service से आने वाले सारे sessions force-close करने को कहा.
3. इसे कैसे रोकें / defend कैसे करें (यह lesson: session defence checklist)
क्यों: password अगले login को protect करता है. वह पहले से खुला session बंद नहीं करता. इसलिए "password बदलो" और "सारे sessions kill करो" हमेशा साथ में करना है.
अगर आप login system बनाते हैं (जैसे broker या banking app):
- Password change या reset होने पर server पर उस user के सारे sessions delete करें, सिर्फ़ current browser की cookie नहीं. PHP में उदाहरण: users table में
session_versionजैसा एक number रखें, password बदलने पर उसमें 1 जोड़ें, और हर request पर उसे$_SESSIONमें save किए number से compare करें; अलग हो तोsession_destroy()call करें. - Users को "Log out of all devices" button दें, और support team को admin "kill sessions" button दें.
- पैसों वाले actions से पहले फिर से MFA माँगें (trade, withdrawal, नया bank account), logged-in session के अंदर भी.
- छोटा idle timeout और absolute timeout रखें, ताकि पुराने sessions अपने आप खत्म हो जाएँ.
- नए device या नए network से session शुरू हो तो user को alert भेजें, और active sessions की list दिखाएँ.
अगर आप दूसरों के लिए servers चलाते हैं (cloud या hosting provider):
- अपने management systems को customer servers से अलग रखें, ताकि एक break-in से सारे customers तक न पहुँचा जा सके.
- एक साथ कई customer servers पर नए programs दिखें तो ध्यान दें, और तुरंत बंद करने के लिए तैयार रहें (malware confirm होने के लगभग एक दिन के अंदर GMO ने servers बंद करने शुरू किए).
4. यह दोबारा न हो, इसके लिए क्या ध्यान रखें (checklist)
- [ ] Account को लेकर कोई शक हो तो: clean device से password बदलें, फिर सारे sessions से logout करें, फिर history check करें.
- [ ] Trading, bank और email accounts पर two-step verification चालू करें.
- [ ] Shared या किराए के server पर passwords plain text में या saved logins की तरह न रखें. Password manager इस्तेमाल करें और हर service के लिए अलग password रखें.
- [ ] Builders: खुद test करें – दो browsers में login करें, एक में password बदलें, और check करें कि दूसरा logout हुआ या नहीं.
- [ ] Builders: हर पैसों वाले action के लिए fresh MFA माँगें.
- [ ] Blackmailer को कभी पैसे न दें. पैसे देने पर भी चोरी हुआ data delete होगा, इसकी कोई guarantee नहीं. Police में report करें.
- [ ] Incident के बाद नकली "refund" या "compensation" emails आएँगे, यह मानकर चलें. ऐसे message की वजह से password या PIN कभी share न करें.
स्रोत: GMO Internet, "Notice and Apology Regarding Unauthorized Access to Onamae.com Desktop Cloud" – Third Report (23 अक्टूबर 2026) and Fourth Report (24 अक्टूबर 2026); GMO Internet, "Renewed Request to Customers Using Onamae.com Desktop Cloud" – Fifth Report (24 अक्टूबर 2026); BleepingComputer, "Japan's Onamae Desktop Cloud hacked, up to 27,000 servers affected", 21 अक्टूबर 2026.
Check if you're safe: Password Strength Checker