Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
astro-mail-obfuscation
Advanced tools
Protect email addresses, phone numbers, and other sensitive data from bots scraping the source code of your Astro apps.
✅ Supported HTML tags: h1
to h6
, p
, span
, a
, label
, ul
, ol
, li
, strong
, b
, em
, i
.
This Astro integration effectively prevents spam bots from extracting email addresses, phone numbers or other sensitive data from the source code of your website. You can manually select one of three methods or activate random mode to increase variation and make it harder for bots to extract data. The integration has been designed with a focus on stability, reliability, performance and seamless support for <ViewTransitions />
.
Note: Server-side rendering is currently not supported.
Install (recommended via Astro CLI):
npx astro add astro-mail-obfuscation
Add the data-obfuscation
attribute to any HTML tag containing sensitive content to obfuscate it during the build process. You can use the values 1
, 2
or 3
to manually select the method for the respective tag.
Alternatively, you can use data-obfuscation="0"
to specify that the integration automatically selects one of the three methods at random during the build, which increases variability and makes interpretation by simple bots even more difficult.
Examples:
<!-- Manually select obfuscation method: -->
<a href="mailto:info@..." data-obfuscation="1">info@...</a>
<a href="tel:0123..." data-obfuscation="2">0123...</a>
<p>...<span data-obfuscation="3">info@...</span>...</p>
<!-- Automatically select a random obfuscation method: -->
<ul data-obfuscation="0">
<li>John Doe</li>
<li>Jane Doe</li>
</ul>
<label data-obfuscation="0">info@...</label>
<!-- Additional content... -->
Info: HTML tags that do not contain the
data-obfuscation
attribute are not obfuscated. This can be useful in certain situations (e.g. GDPR).
This integration works out of the box with no required setup.
Nevertheless, a few settings can be made to control the behavior of the integration:
// astro.config.mjs
import mailObfuscation from "astro-mail-obfuscation";
export default defineConfig({
integrations: [
mailObfuscation({
fallbackText: "Please enable JavaScript", // Default: "[PROTECTED!]"
// userKey: "...", // Automatically generated
// userSalt: "...", // Automatically generated (must be 8 characters if set manually)
// concurrencyLimit: number, // Max concurrent tasks, default: 5 (p-limit)
// allowedTags: ["button", "..."] // Add unsupported HTML tags to the whitelist
}),
],
});
The fallbackText
is displayed if the user has deactivated JavaScript in the browser.
Whenever you run the build process, userKey
and userSalt
are automatically regenerated by default. If you still want to set static values within your Astro configuration, please note that the userSalt
must be exactly 8 characters long. The length of the userKey
, on the other hand, is not limited.
The userKey
and userSalt
are set as a meta tag on all pages during the build process to make them accessible to the client-side JavaScript.
Please change the concurrencyLimit
with caution, as a value that is too high could affect stability.
By default, 17 HTML tags are already supported, but if you still need support for more tags, add them to the allowedTags
array.
Recommendation: In most cases, only the
fallbackText
needs to be adjusted. The default settings are already optimized for stable use.
The integration provides three XOR-based methods for obfuscation:
userKey
, resulting in hexadecimal encoding.userKey
, resulting in Base64 encoding (dynamically reversed).userKey
and userSalt
, resulting in Base62 encoding.Each method uses XOR-based encoding with additional keys to vary how the content is represented, making it harder for simpler bots to detect patterns. For increased variability, data-obfuscation="0"
enables automatic mode, which randomly selects a method during the build to further complicate bot interpretation.
While the majority of basic bots cannot execute JavaScript, this integration provides a practical level of protection for simpler, common bots. Astro Mail Obfuscation is a client-side solution ideal for static sites.
FAQs
Protect email addresses, phone numbers and other sensitive data from bots scraping the source code of your Astro app.
The npm package astro-mail-obfuscation receives a total of 3 weekly downloads. As such, astro-mail-obfuscation popularity was classified as not popular.
We found that astro-mail-obfuscation demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.