<?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: Iannetta</title>
    <description>The latest articles on DEV Community by Iannetta (@iannetta).</description>
    <link>https://dev.to/iannetta</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1414226%2Fa9485a94-d573-4a90-8dca-46a051f34a17.jpg</url>
      <title>DEV Community: Iannetta</title>
      <link>https://dev.to/iannetta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iannetta"/>
    <language>en</language>
    <item>
      <title>Utilities</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 17 Apr 2024 23:53:34 +0000</pubDate>
      <link>https://dev.to/iannetta/utilities-1cbb</link>
      <guid>https://dev.to/iannetta/utilities-1cbb</guid>
      <description>&lt;p&gt;Here are some tools, techniques, ideas and anything else that might be useful in everyday life.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ray.so/"&gt;ray.so&lt;/a&gt;&lt;br&gt;
Do you ever find yourself needing to include code examples in documentation or presentations? Now, you can streamline that process by using this tool to generate images of your code snippets. No more wasting time formatting and adjusting code manually. With this tool, you can quickly and easily create images of your snippets, adding a professional touch to your documentation and presentations.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://sli.dev/"&gt;sli.dev&lt;/a&gt;&lt;br&gt;
Nothing beats crafting presentations as code! Slidev, powered by Vite and Vue, allows customization, creation of reusable components, and layouts.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://gchq.github.io/CyberChef/"&gt;CyberChef&lt;/a&gt;&lt;br&gt;
This website is a collection of utilities for information security. Here's how it works: you assemble a pipeline, adding functions like encoding and hashing, then provide an input, and it generates an output based on the pipeline.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://mermaid.live/"&gt;Mermaid Live&lt;/a&gt;&lt;br&gt;
Have you ever needed to generate a workflow using tools like draw.io? Wouldn't it be great to have that as code? Well, now you can have it all: editable, shareable, and codable.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://typer.tiangolo.com/"&gt;Typer&lt;/a&gt;&lt;br&gt;
If you need to build a command-line tool and know Python, this little guy here is going to be a huge help.&lt;/p&gt;



&lt;p&gt;&lt;a href="https://github.com/chubin/cheat.sh"&gt;Cheat.sh&lt;/a&gt;&lt;br&gt;
Command-line heat-sheet that has more than 50 languages.&lt;br&gt;
The coolest thing is that it works directly in the terminal via &lt;code&gt;curl&lt;/code&gt;.&lt;br&gt;
Command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl cht.sh/python/lambda
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Lambda are anonymous functions in Python by using the keyword lambda
# Therefore they are not bound to a name
​
# Simple Lambda Function
a = lambda parameter: parameter + 40
#
print (a(2))                    # Outputs 42
​
# Lambda Functions Inside Real Functions
def subtract_func(n) :
    return lambda x: x - n
#
a = subtract_func(1)            # Sets n to 1 for a
b = subtract_func(2)            # Sets n to 2 for b
#
print(a(-4))                    # Outputs -5 ( -5 = -4 - 1 )
print(b(-2))                    # Outputs -4 ( -4 = -2 - 2 )
​
# Lambda Function with Multiple Parameters
f = lambda x, y : x + y
#
print( f(1,1) )                 # Outputs 2 ( 1 + 1 )
​
# map() + lambda functions
a = [1, 2, 3, 4, 5]
b = [1, 2, 3, 4, 5]
#
r = map(lambda x,y : x+y, a,b)  # map() will return an iterator
r_list = list(r)                # listify r
print(r_list)                   # prints [2, 4, 6, 8, 10]
​
# filter() + lambda functions
# Program to filter out only the even items from a list
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
#
new_list = list(filter(lambda x: (x%2 == 0) , my_list))
#
print(new_list)                 # Output: [4, 6, 8, 12]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Cloud</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 17 Apr 2024 23:14:18 +0000</pubDate>
      <link>https://dev.to/iannetta/cloud-ieo</link>
      <guid>https://dev.to/iannetta/cloud-ieo</guid>
      <description>&lt;p&gt;&lt;strong&gt;Guias&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/iannetta/aws-17ch"&gt;AWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/iannetta/azure-fnl"&gt;Azure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/deepfence/ThreatMapper"&gt;​ThreatMapper&lt;/a&gt;: Open source cloud native security observability platform. Linux, K8s, AWS Fargate and more.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.pulumi.com/"&gt;​Pulumi&lt;/a&gt; - IaC: Infrastructure as code using languages we already know.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Usefull links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/4ndersonLin/awesome-cloud-security?utm_content=buffere7268&amp;amp;utm_medium=social&amp;amp;utm_source=linkedin.com&amp;amp;utm_campaign=buffer"&gt;Github :: Awesome Cloud Security by 4ndersonLin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>aws</category>
      <category>azure</category>
      <category>threatmapper</category>
    </item>
    <item>
      <title>Secret Management</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Mon, 15 Apr 2024 14:32:34 +0000</pubDate>
      <link>https://dev.to/iannetta/secret-management-3dki</link>
      <guid>https://dev.to/iannetta/secret-management-3dki</guid>
      <description>&lt;p&gt;When we are developing our solutions, it is common for us to need to connect different services. These services commonly require some type of credential, apikey, token or any access information. As an example, we have database access credentials, Google API keys, digital certificates, AWS credentials, etc. But what would happen if this information fell into the wrong hands?&lt;/p&gt;

&lt;p&gt;For this reason we need to be careful with some information!&lt;/p&gt;




&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Secrets in the Code&lt;/strong&gt;&lt;br&gt;
We must not leave any secret fixed in the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Secret hardcoded
// 🚫 BAD
const db = new DB({
  user: 'DbUser',
  pass: 'DbP@ss0rd!'
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;To solve this, we can use &lt;code&gt;Environment Variables&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// ✅ GOOD
const db = new DB({
  user: process.env.DB_USER,
  pass: process.env.DB_PASS
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Or Password Vault:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hashicorp vault
const vault = require("node-vault")({
  apiVersion: process.env.VAULT_VERSION,
  endpoint: process.env.VAULT_URL,
});
​
const roleId = process.env.ROLE_ID;
const secretId = process.env.SECRET_ID;
​
const run = async () =&amp;gt; {
  const result = await vault.approleLogin({
    role_id: roleId,
    secret_id: secretId,
  });
​
  vault.token = result.auth.client_token;
​
  const { data } = await vault.read("secret/data/mysql/webapp");
​
  const databaseName = data.data.db_name;
  const username = data.data.username;
  const password = data.data.password;
​
  console.log({
    databaseName,
    username,
    password,
  });
};
​
run();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;This type of information can be in several places:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Code&lt;/li&gt;
&lt;li&gt;Settings Files (web.config, .env, application.properties, etc.)&lt;/li&gt;
&lt;li&gt;READMEs&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Access Management
&lt;/h2&gt;

&lt;p&gt;Ok, we've already removed the secrets found in the code, wikis, etc. But what about the access information that people need to have, such as a bank consultation credential or log panel, what does that look like? How will the development team fix a problem or gain access to the platforms?&lt;/p&gt;

&lt;p&gt;It is common for team members to have passwords, certificates or keys to access environments and tools. Taking care of this information is also important.&lt;/p&gt;

&lt;p&gt;To do this, some precautions need to be taken:&lt;/p&gt;




&lt;h2&gt;
  
  
  Nominal Credentials
&lt;/h2&gt;

&lt;p&gt;Each team member who has access to a tool or platform must have their own credential, with a specific profile for their needs.&lt;br&gt;
​&lt;/p&gt;


&lt;h2&gt;
  
  
  Access Scope
&lt;/h2&gt;

&lt;p&gt;When problems occur in production or a new functionality requires an analysis of the environment to avoid breaking changes, the team needs information.&lt;/p&gt;

&lt;p&gt;Instead of restricting access to everything, creating friction and delaying work demands, let's focus on one question:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;What needs to be protected?&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You may come to the conclusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They cannot perform write operations.&lt;/li&gt;
&lt;li&gt;They cannot access personal, sensitive and confidential data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Great, this is where the work is.&lt;br&gt;
Reach out to the team and say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey people, we're giving you freedom, we're just not going to enable access to people's data and writing operations so as not to compromise the environment, okay?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's MUCH better than asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What do you need?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the simple reason that in a WAR ROOM no one knows what they need (besides coffee and an aspirin, of course) and in the end you need to give access to everything because of the pressure.&lt;/p&gt;


&lt;h2&gt;
  
  
  Scratchs
&lt;/h2&gt;

&lt;p&gt;​​&lt;br&gt;
&lt;a href="https://cwe.mitre.org/data/definitions/798.html"&gt;CWE-798: Use of Hard-coded Credencials&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Someone unauthorized has access to production credentials simply because they have access to the source code or documentation.&lt;/li&gt;
&lt;li&gt;Someone put the code in a public environment (public personal github, pastebin, etc.) and the secrets were leaked.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Guides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://owaspsamm.org/model/implementation/secure-deployment/stream-b/"&gt;SAMM - Secret Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Key_Management_Cheat_Sheet.html"&gt;OWASP Cheat Sheet - Key Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://owasp.org/www-project-proactive-controls/v3/en/c8-protect-data-everywhere"&gt;OWASP Proactive Controls - C8 - Protect Data Everywhere&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html"&gt;OWASP Cheat Sheet - Cryptographic Storage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://bitwarden.com/"&gt;Bitwarden&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Password manager (personal / teams).&lt;/li&gt;
&lt;li&gt;For personal use, it is free, open source and can be used on multiple devices.&lt;/li&gt;
&lt;li&gt;For companies, it can be used as a vault.&lt;/li&gt;
&lt;li&gt;We recommend bitwarden for personal password manager use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.passbolt.com/"&gt;Passbolt&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open source password manager for teams.&lt;/li&gt;
&lt;li&gt;It can be installed in different ways, but the main thing: it has a docker-compose.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.vaultproject.io/"&gt;Hashicorp Vault&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vault for storing passwords, certificates or any other sensitive information.&lt;/li&gt;
&lt;li&gt;There is a free and self-hosted option.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/trufflesecurity/trufflehog"&gt;Trufflehog&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Command line tool for detecting hardcoded secrets.&lt;/li&gt;
&lt;li&gt;It runs on docker and is capable of detecting more than 700 types of credentials.&lt;/li&gt;
&lt;li&gt;You can scan Github, Gitlab, FileSystem, Logs and S3 Buckets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trufflehog with Docker&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it -v "$PWD:/pwd" \
    trufflesecurity/trufflehog:latest \
    github \
    --org=trufflesecurity
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://docs.gitlab.com/ee/user/application_security/secret_detection/"&gt;Gitlab - Secret Detection&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gitlab (in all its versions) natively has a scan for hard-coded secrets.&lt;/li&gt;
&lt;li&gt;The free version is limited compared to the ultimate, but it is a great option if the company does not want to adopt an external tool or wants to use 100% of the platform they already pay for.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;Github - Secret Scanning&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Github has a built-in secret scan as well.&lt;/li&gt;
&lt;li&gt;It runs automatically in all repositories, but there are extra options if Advanced Security is purchased.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Usefull Links
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tutorials&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.hashicorp.com/resources/creating-nodejs-app-record-retrieve-secret-vault"&gt;Creating a Node.js App that Records and Retrives Secrets from Vault&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository"&gt;Github :: Removing sensitive data from a repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://howtorotate.com/docs/introduction/getting-started/"&gt;Truffle :: How to Rotate Tutorials&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Videos&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://youtu.be/s7ldn31OEFc"&gt;Fabio Akita :: Your Security Sucks | Password Managers, 2FA, Encryption&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>vault</category>
      <category>credential</category>
      <category>apikey</category>
      <category>token</category>
    </item>
    <item>
      <title>Azure</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Thu, 11 Apr 2024 22:21:13 +0000</pubDate>
      <link>https://dev.to/iannetta/azure-fnl</link>
      <guid>https://dev.to/iannetta/azure-fnl</guid>
      <description>&lt;h2&gt;
  
  
  Guides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/secure/"&gt;Security in the Microsoft Cloud Adoption Framework for Azure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where to learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://acloudguru.com/learning-paths/azure-security"&gt;A Cloud Guru - Azure Security&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>cloud</category>
      <category>microsoft</category>
    </item>
    <item>
      <title>AWS</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Thu, 11 Apr 2024 22:17:31 +0000</pubDate>
      <link>https://dev.to/iannetta/aws-17ch</link>
      <guid>https://dev.to/iannetta/aws-17ch</guid>
      <description>&lt;h2&gt;
  
  
  Guides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/pt/architecture/security-identity-compliance/?cards-all.sort-by=item.additionalFields.sortDate&amp;amp;cards-all.sort-order=desc&amp;amp;awsf.content-type=*all&amp;amp;awsf.methodology=*all"&gt;AWS Official - Best security practices, identities and compliance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/pdfs/whitepapers/latest/aws-security-incident-response-guide/aws-security-incident-response-guide.pdf#aws-security-incident-response-guide"&gt;AWS Security Incident Response Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where to learn
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://application.security/free/kontra-aws-clould-top-10"&gt;Kontra - AWS Top 10&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://acloudguru.com/learning-paths/aws-security"&gt;A Cloud Guru - AWS Security&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/c/LoiLiangYang"&gt;Youtube - Loi Liang Yang &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cloud</category>
      <category>aws</category>
    </item>
    <item>
      <title>JWT</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Thu, 11 Apr 2024 13:33:32 +0000</pubDate>
      <link>https://dev.to/iannetta/jwt-ail</link>
      <guid>https://dev.to/iannetta/jwt-ail</guid>
      <description>&lt;h2&gt;
  
  
  Fast Guide
&lt;/h2&gt;

&lt;p&gt;Here are the main precautions when using JWT tokens:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Use a strong signature&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we sign our token, we need to use a sizable secret.&lt;/p&gt;

&lt;p&gt;We can sign a JWT token in several ways, but the main ones are using symmetric (&lt;strong&gt;HS256&lt;/strong&gt;, &lt;strong&gt;HMAC + SHA-256&lt;/strong&gt;) and asymmetric (&lt;strong&gt;RS256&lt;/strong&gt;, &lt;strong&gt;RSA + SHA-256&lt;/strong&gt;) keys.&lt;/p&gt;

&lt;p&gt;As a recommendation, it is better to use asymmetric signature, since:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only one service can generate the token (using private key), while other services can only verify it (public key).&lt;/li&gt;
&lt;li&gt;If the private key is compromised, rotating it does not break other applications with the current token, after all, the public verification keys will continue to work.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;JWT with asymmetric key&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fs = require('fs');
const jwt = require('jsonwebtoken');
​
// use 'utf8' to get string instead of byte array  (512 bit key)
const privateKEY = fs.readFileSync('./private.key', 'utf8');
const publicKEY = fs.readFileSync('./public.key', 'utf8');
​
const payload = {
  name: 'Gandalf'
}
​
// SIGN
const signOptions = {
  issuer: "Authorizaxtion/Resource/This server",
  subject: "iam@user.me",
  audience: "Client_Identity",
  expiresIn: "1d",
  algorithm: "RS256"
};
​
const token = jwt.sign(payload, privateKEY, signOptions);
console.log('\n\n=== TOKEN ===');
console.log(token);
​
​
// VERIFY
var verifyOptions = {
  issuer: "Authorizaxtion/Resource/This server",
  subject: "iam@user.me",
  audience: "Client_Identity",
  expiresIn: "1d",
  algorithm: "RS256"
};
​
const verified = jwt.verify(token, publicKEY, verifyOptions);
console.log('\n\n=== VERIFIED ===');
console.log(verified);
​
​
// DECODE
const decoded = jwt.decode(token, { complete: true });
console.log('\n\n=== DECODED ===');
console.log(decoded);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;/p&gt;




&lt;p&gt;See a functional example at &lt;a href="https://replit.com/@bhrott/JWT-RS256-Nodejs#index.js"&gt;Replit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Always define the algorithm when performing the check&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There is a type of vulnerability that occurs in some JWT configurations which is the &lt;a href="https://blog.pentesteracademy.com/hacking-jwt-tokens-the-none-algorithm-67c14bb15771"&gt;None Algorithm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In summary, the attacker changes the JWT header to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "typ": "JWT",
  "alg": "none"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in the backend the lib we use takes the alg value and ignores the verification key.&lt;br&gt;
To prevent this from happening, we must always define the alg when checking the token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var verifyOptions = {
  //...
  algorithm: "RS256"
};
​
const verified = jwt.verify(token, publicKEY, verifyOptions);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Usefull links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jwt.io/"&gt;Official Site - jwt.io&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.rfc-editor.org/rfc/rfc7519"&gt;RFC 7519&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://token.dev/"&gt;tokens.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://portswigger.net/web-security/jwt"&gt;Portswigger Academy - JWT Attacks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://auth0.com/docs/secure/tokens/json-web-tokens"&gt;Auth0 - JWT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Articles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://danaepp.com/how-to-use-azure-to-crack-api-auth-tokens"&gt;How to use Azure to crack API auth tokens&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>jwt</category>
      <category>security</category>
      <category>token</category>
    </item>
    <item>
      <title>Bot Protection</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 22:52:35 +0000</pubDate>
      <link>https://dev.to/iannetta/bot-protection-32kc</link>
      <guid>https://dev.to/iannetta/bot-protection-32kc</guid>
      <description>&lt;h2&gt;
  
  
  Technologies
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise"&gt;reCaptcha Enterprise&lt;/a&gt;&lt;br&gt;
The recaptcha enterprise its a little solutions has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Option to be invisible (do not require user interaction).&lt;/li&gt;
&lt;li&gt;SDK Web and Mobile.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Usefull links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise/docs/libraries?hl=en"&gt;Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise/docs/instrument-web-pages"&gt;SDK Web&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise/docs/instrument-android-apps"&gt;SDK Android&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps"&gt;SDK iOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cloud.google.com/recaptcha-enterprise/pricing?hl=pt-br#recaptcha-enterprise-pricing"&gt;Price&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Articles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.cloudflare.com/turnstile-private-captcha-alternative/"&gt;Cloudflare - Annoucing Turnstile, a user-friendly, privacy-preserving alternate to CAPTCHA &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bot</category>
      <category>protection</category>
      <category>security</category>
    </item>
    <item>
      <title>SBOM, Libs e Components</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 14:13:38 +0000</pubDate>
      <link>https://dev.to/iannetta/sbom-libs-e-components-59pi</link>
      <guid>https://dev.to/iannetta/sbom-libs-e-components-59pi</guid>
      <description>&lt;p&gt;&lt;strong&gt;Knowledge base&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/awesomeSBOM/awesome-sbom"&gt;Awesome SBOM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Articles&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.aquia.us/blog/2022-09-27-owasp-scvs/"&gt;Aqua :: OWASP Software Component Verification Standard (SCVS)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.csoonline.com/article/3667483/8-top-sbom-tools-to-consider.html"&gt;CSO Online :: 8 top SBOM tools to consider&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mergebase.com/blog/best-tools-for-generating-sbom/"&gt;MergeBase :: What are the Best Tools for Generating SBOM (Software Bill of Materials)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://anchore.com/sbom/how-to-generate-an-sbom-with-free-open-source-tools/"&gt;Anchore :: How to Generate an SBOM with Free Open Source Tools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://owasp.org/www-project-dependency-check/"&gt;OWASP Dependency-Check&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dependencytrack.org/"&gt;OWASP Dependency Track&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cyclonedx.org/"&gt;CycloneDX&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/anchore/syft"&gt;anchore/syft&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/microsoft/sbom-tool"&gt;microsoft/sbom-tool&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://osv.dev/"&gt;OSV by Google: A distributed vulnerability database for Open Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>sbom</category>
      <category>libs</category>
    </item>
    <item>
      <title>Threat Modeling</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 13:48:07 +0000</pubDate>
      <link>https://dev.to/iannetta/threat-modeling-gel</link>
      <guid>https://dev.to/iannetta/threat-modeling-gel</guid>
      <description>&lt;p&gt;&lt;strong&gt;Guides&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.threatmodelingmanifesto.org/"&gt;Threat Modeling Manifesto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://owasp.org/www-community/Threat_Modeling_Process"&gt;OWASP :: Threat Modeling Process&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.microsoft.com/en-us/securityengineering/sdl/threatmodeling"&gt;Microsoft :: Threat Modeling &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Usefull links&lt;/strong&gt;&lt;br&gt;
Articles&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://about.gitlab.com/handbook/security/threat_modeling/"&gt;Gitlab :: Threat Modeling &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Tools&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://threatdragon.github.io/"&gt;OWASP Threat Dragon&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>threat</category>
      <category>modeling</category>
      <category>owasp</category>
      <category>stride</category>
    </item>
    <item>
      <title>DevSecOps</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 12:48:56 +0000</pubDate>
      <link>https://dev.to/iannetta/devsecops-2pj</link>
      <guid>https://dev.to/iannetta/devsecops-2pj</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;DevSecOps is a practice with a focus on automation, testing, and security verifications within the DevOps flow. It's a methodology comprising methods, techniques, and processes to connect development, security, and operations throughout all stages of DevOps: Plan, Code, Build, Test, Release, Deploy, Operate, and Monitor.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Where to learn!&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://tryhackme.com/room/introtopipelineautomation"&gt;TryHackMe :: Intro to Pipeline Automation&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Usefull links&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/sottlmarek/DevSecOps"&gt;Github :: Ultimate DevSecOps Library by sottlmarek&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/hahwul/DevSecOps"&gt;Github :: DevSecOps Roadmap by hahwul&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devsecops</category>
      <category>security</category>
    </item>
    <item>
      <title>DAST</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 11:44:25 +0000</pubDate>
      <link>https://dev.to/iannetta/dast-5ap3</link>
      <guid>https://dev.to/iannetta/dast-5ap3</guid>
      <description>&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://portswigger.net/burp/dastardly"&gt;Dastardly&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lightweight web application security scanner for your CI/CD pipeline. Free, from creators of BurpSuite.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.zaproxy.org/"&gt;OWASP Zap&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The OWASP Zed Attack Proxy (ZAP) is one of the world’s most popular free security tools and is actively maintained by a dedicated international team of volunteers. It can help you automatically find security vulnerabilities in your web applications while you are developing and testing your applications. It's also a great tool for experienced pentesters to use for manual security testing.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://github.com/projectdiscovery/nuclei"&gt;Nuclei&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nuclei is used to send requests across targets based on a template, leading to zero false positives and providing fast scanning on a large number of hosts. Nuclei offers scanning for a variety of protocols, including TCP, DNS, HTTP, SSL, File, Whois, Websocket, Headless etc. With powerful and flexible templating, Nuclei can be used to model all kinds of security checks.&lt;/p&gt;

</description>
      <category>dast</category>
      <category>devsecops</category>
      <category>security</category>
      <category>pipeline</category>
    </item>
    <item>
      <title>Encoding</title>
      <dc:creator>Iannetta</dc:creator>
      <pubDate>Wed, 10 Apr 2024 00:59:27 +0000</pubDate>
      <link>https://dev.to/iannetta/encoding-1ooj</link>
      <guid>https://dev.to/iannetta/encoding-1ooj</guid>
      <description>&lt;p&gt;In computing, encoding is the process of transforming a sequence of characters (letters, numbers, punctuation, special characters, symbols) into a format that is efficient for transmission and storage. The format commonly used is . It works something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main
​
import (
  b64 "encoding/base64"
  "fmt"
)
​
func main() {
  // Here is the string to be encoded.
  data := "abc123!?$*&amp;amp;()'-=@~"
​
  // We performed the encoding.
  sEnc := b64.StdEncoding.EncodeToString([]byte(data))
  fmt.Println(sEnc)
​
  // We performed the decoding.
  sDec, _ := b64.StdEncoding.DecodeString(sEnc)
  fmt.Println(string(sDec))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;YWJjMTIzIT8kKiYoKSctPUB+
abc123!?$*&amp;amp;()'-=@~
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;"Okay, but what will we use this for?" You might be wondering.&lt;/p&gt;

&lt;p&gt;Imagine yourself needing to transfer a snippet of code to another computer.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main
​
import (
    "fmt"
    "net/url"
)
​
func main() {
    s := "this will be esc@ped!"
    fmt.Println("http://example.com/say?message="+url.QueryEscape(s))
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;We have new lines, special characters, etc...&lt;br&gt;
Perhaps some information may be lost in the middle of this process depending on the content being transmitted.&lt;br&gt;
So transmitting this value here is better, isn't it?&lt;/p&gt;

&lt;p&gt;Base64&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;p&gt;You can test it yourself with the &lt;a href="https://it-tools.tech/base64-string-converter"&gt;IT-TOOLS&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;Before we move on to the next topic, it's worth remembering:&lt;br&gt;
&lt;strong&gt;Encoding is NOT CRYPTOGRAPHY.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>encoding</category>
      <category>base64</category>
      <category>go</category>
      <category>ittools</category>
    </item>
  </channel>
</rss>
