EZ LearnEZ Learn
Courses
EZ Board
Dashboard
All articles
ml-for-cyber-securitymlcsphishingbusiness-email-compromise

Combining Text and Structural Features for Phishing

The FBI's IC3 reported roughly 2.9 billion dollars in business email compromise losses in 2023, often with no malicious attachment at all. Structural features, sender-link mismatches and urgency language, matter as much as any file-based signal.

Ashish Revar25 October 20265 min read

ML concept: Beyond Bag-of-Words: Structural Email Features

Pure text features miss structural signals a phishing email almost always carries. Combining TF-IDF text features with hand-engineered structural features, mismatched display and actual link URLs, sender domain age, HTML-to-plain-text ratio, count of urgency words ("immediately," "suspended," "verify now"), consistently outperforms either feature family alone.

Which features actually drive a phishing-email classifierNum. urgent/action wordsMismatched display/actual URLCount of embedded URLsSender domain age (days)HTML-to-text ratioCount of spelling errorsHas attachmentSubject line lengthCount of exclamation marksReply-to differs from FromRelative importance (Gini decrease)
Feature importances from a Random Forest trained on exactly this mix of structural and text-derived features. The two highest-ranked features are both structural, not raw word counts

Case study: Business Email Compromise: When Phishing Has No Malware At All

The FBI's Internet Crime Complaint Center (IC3) reported roughly $2.9 billion in adjusted losses from business email compromise (BEC) complaints in its 2023 Internet Crime Report, making BEC one of the two costliest categories of cybercrime it tracks. A BEC attack often contains no malicious attachment and no malware payload at all, only a carefully worded email impersonating an executive or vendor, requesting an urgent wire transfer. This is precisely why the structural and linguistic features built in this unit, urgency language, sender-display mismatches, unusual request patterns, matter as much as, or more than, any file-based signal: many of the costliest phishing attacks in the world have no file to analyse in the first place.

  1. Extract TF-IDF features from the subject and body text.
  2. Extract structural features: link-domain mismatch, sender domain age, urgency word count, HTML ratio, attachment presence.
  3. Concatenate both feature sets into a single vector per email (scipy.sparse.hstack for mixed sparse/dense features).
  4. Train and evaluate exactly as in Unit 2, using the same train/test split discipline.
  5. Inspect feature importances, as in the chart above, to confirm the model is learning genuine signal, not an artefact of this particular dataset.

Caution: Feature Leakage

A dataset of phishing emails scraped from a public reporting feed may contain a feature that is a side effect of how the data was collected, not a property of phishing itself, for example, every phishing sample arriving with a specific mail header the reporting tool adds. A model trained on that dataset will look excellent and fail immediately in production, because it learned the collection artefact, not phishing. Always ask, for every strong feature: could this value exist for a reason unrelated to the label?

Try it yourself: Build Your Own Structural Feature

Using any public phishing-email dataset or a small one you construct from your own spam folder (with personal data stripped), write a function that returns True if an email's visible link text and its actual href target point to different domains. Add it as a feature to the pipeline above and check whether it appears near the top of the feature-importance ranking.

Key takeaway

Feature engineering, not classifier choice, is usually what separates a strong security model from a weak one. Network-flow features summarise packet-level behaviour into fixed vectors; static malware features, especially entropy, expose structure without ever running a file; phishing detection combines TF-IDF text features with structural signals like sender-link mismatches, because many of the costliest real attacks, such as business email compromise, carry no malware payload to analyse at all.

Related to this topic

Continue learning

Reference material

eBook

ML for Cyber Security eBook

v1.0

Open resource

Cheatsheet

ML for Cyber Security Cheatsheet

v1.0

Open resource

MCQ Bank

ML for Cyber Security MCQ Bank

v1.0

Open resource

Question Bank

ML for Cyber Security Question Bank

v1.0

Open resource

Discussion

Loading comments…
More articlesTest your knowledge
EZ MentorAI · Free

Combining Text and Structural Features for Phishing

Hi! I'm EZ Mentor

Your AI tutor for
Combining Text and Structural Features for Phishing

Sign in to ask, it's free.

EZ Mentor is AI-powered · Answers may not be perfect · 10 free questions / day

EZ Learn

Structured learning across Reverse Engineering, Cloud Security and Research Methodology, plus games and practice tools. Free, and open to anyone.

Learn

  • Courses
  • EZ Articles
  • EZ Watch
  • EZ Bytes
  • EZ Talks
  • Community

Library & Exams

  • All Resources
  • eBooks & PDFs
  • Question Banks
  • Cheatsheets
  • All Exams
  • EZ Board

EZ Arena

  • EZ Games
  • Byte Rush
  • Firewall Defence
  • 3D Case Files
  • Live Quiz
  • ML Challenges

EZ Cyber Hygiene

  • Hygiene Journey
  • Cyber Safety Check
  • दिशा - Hygiene
  • सजग - Awareness
  • अभ्यास - Practice
  • Scammed? Call 1930

Platform

  • About
  • Contact
  • Events
  • Verify Certificate
  • Terms of Use
  • Disclaimer

© 2026 EZ Learn by EpochZero. Educational content for learning purposes.

Platform Lead: Ashish Revar