Add blog post

This commit is contained in:
Kevin Kandlbinder 2021-12-24 02:16:54 +00:00 committed by GitHub
parent a22002c150
commit d39e41cf4b
14 changed files with 188 additions and 32 deletions

View file

@ -0,0 +1,58 @@
---
section: general
language: de
title: "Never trust user input: Gratis Pizza"
url: never-trust-user-input
tags: [security]
published: 2018-03-10 22:00:00
author:
name: Kevin Kandlbinder
embeddedImagesLocal:
- './assets/001-free-pizza/firefox_2018-03-10_11-51-08-e1520680515546.png'
---
import { getImage, GatsbyImage } from 'gatsby-plugin-image';
> „Never trust user input“
Diese einfache Regel der Web-Sicherheit sollte jeder Web-Entwickler schon mal gehört haben, doch trotzdem gibt es noch immer viele Entwickler, die sich nicht genug darum kümmern und genau das wird vielen Seiten zum Verhängnis.
## Das Casino
Als ich mir vor kurzem Sushi auf [Pizza.de](https://web.archive.org/web/20180303184257/https://pizza.de/) (Ja, ich sehe den Wiederspruch) bestellt habe wurde mir auf der Bestellbestätigungs-Seite Werbung für das so genannte [Pizza.de-Casino](https://web.archive.org/web/20180306155955/https://pizza.de/casino/) angezeigt. Da ich eh auf meine Bestellung warten musste und man nichts beahlen muss dachte ich mir, dass man das ja mal probieren kann.
![Wie gespielt werden soll...](./assets/001-free-pizza/2018-03-10_11-49-12.gif)
Nach 9 von 10 täglichen Versuchen war ich schließlich frustriert: „Es muss doch irgend einen anderen Weg geben…“ Also habe ich mir die Netzwerkaktivität wärend des Spielens angesehen: Eine Anfrage an Facebook und eine an Google, beides Analytics. Folglich muss mein eigener Browser berechnen, ob ich gewonnen habe oder nicht.
## Der Code
Nachdem ich das sah war die Challenge nicht mehr zu ignorieren: ICH WILL GEWINNEN!
Also habe ich mich durch den Code gewühlt und mir fielen mehrere Variablen auf, die offensichtlich für die Gewinnchancen zuständig sind. (Fun Fact: Die Chance beim ersten Versuch ist größer als bei allen weiteren) Als ich aber mit denen ein bisschen ohne Ergebnis rumgespielt habe, habe ich mich direkt in die Funktionen gesetzt und nachvollzogen was das Programm genau macht wenn ich den Button drücke, und da war es: In Zeile 203
fand sich die Funktion „win“…
<div>
<GatsbyImage alt='win();' image={getImage(props.localImages[0])} />
</div>
Aber das kann doch nicht funktionieren… Die Web-Sicherheit…
## Der Test
Also nichts wie ab damit in die Konsole und…
<div style="display: flex; align-items: center; gap: 20px;">
<img src="./assets/001-free-pizza/2018-03-10_11-52-49.gif" alt="Konsole" width="50%" />
<img src="./assets/001-free-pizza/2018-03-10_11-52-01.gif" alt="Casino" width="50%" />
</div>
…gewonnen, der Code war besiegt, die Challenge gemeistert, die Web-Sicherheit im A**** und ich zufrieden. Toll. Aber was nun? Sich ganz viele Gutscheine auf Prepaid-Nummern holen? Zu anstrengend. Pizza.de Bescheid sagen? Ja, aber nicht genug… Darüber schreiben und eine Moral für jeden Entwickler draus ziehen? Ja, das klingt gut!
## Die Moral von der Geschicht...
**...User-Input trauen tut man nicht.** Selbst große Firmen mit gut bezahlten Entwicklern machen diesen Fehler: Die Performance der Seite wird auf Kosten der Sicherheit verbessert und dem Browser des Benutzers wird blind vertraut. Doch wie kann man so etwas lösen?
Das Casino sollte im Hintergrund seine Ergebnisse auf dem Server generieren, auch wenn es eine kurze Ladezeit gäbe und vom Server einen Token bekommen, mit dem der Gewinn abgeholt werden könnte. Somit würde der Server entscheiden ob ein Gutschein herausgegeben wird und nicht ein hobbyloser Typ mit einem PC.
<small>Importiert aus altem Blog - <a href="https://web.archive.org/web/20201216152631/https://blog.1in9.net/2018/03/never-trust-user-input-gratis-pizza/" target="_blank" rel="noreferrer ">Archiviertes Original</a></small>

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View file

@ -119,6 +119,7 @@ module.exports = {
`gatsby-plugin-eslint`,
`gatsby-plugin-image`,
`gatsby-plugin-sharp`,
`gatsby-remark-images`,
`gatsby-transformer-sharp`,
`gatsby-transformer-json`,
{
@ -170,7 +171,28 @@ module.exports = {
name: `careerContent`,
},
},
"gatsby-plugin-mdx",
{
resolve: `gatsby-plugin-mdx`,
options: {
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-copy-linked-files",
options: {
destinationDir: "mdassets",
},
},
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
showCaptions: true,
markdownCaptions: false,
withWebp: true,
},
},
],
},
},
{
resolve: `gatsby-source-filesystem`,
options: {

View file

@ -24,7 +24,10 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
}
blog: allFile(
filter: { sourceInstanceName: { eq: "blogContent" } }
filter: {
sourceInstanceName: { eq: "blogContent" }
childMdx: { body: { ne: null } }
}
) {
nodes {
childMdx {
@ -94,14 +97,14 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
})
);
let processedSections = ["blog"];
let processedSections = [];
result.data.blog.nodes.forEach((node) => {
if (!node.childMdx) return;
if (
!processedSections.includes(
node.childMdx.frontmatter.section ?? "blog"
node.childMdx.frontmatter.section ?? "general"
)
) {
processedSections.push(node.childMdx.frontmatter.section);
@ -134,16 +137,14 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
reporter.info(
"Creating Page: " +
`/${node.childMdx.frontmatter.language}/blog/${
node.childMdx.frontmatter.section ?? "blog"
node.childMdx.frontmatter.section ?? "general"
}/${node.childMdx.frontmatter.url}`
);
createPage({
path: `/${node.childMdx.frontmatter.language}/blog/${
node.childMdx.frontmatter.section
? node.childMdx.frontmatter.section + "/"
: ""
}${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.section ?? "general"
}/${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.url
}`,
component: blogTemplate,
@ -158,16 +159,12 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
createRedirect({
fromPath: `/${lang}/blog/${
node.childMdx.frontmatter.section
? node.childMdx.frontmatter.section + "/"
: ""
}${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.section ?? "general"
}/${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.url
}`,
toPath: `/${node.childMdx.frontmatter.language}/blog/${
node.childMdx.frontmatter.section
? node.childMdx.frontmatter.section + "/"
: ""
(node.childMdx.frontmatter.section ?? "general") + "/"
}${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.url
}`,
@ -179,10 +176,8 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
createRedirect({
fromPath: `/${lang}/scambox/${node.childMdx.frontmatter.url}`,
toPath: `/${node.childMdx.frontmatter.language}/blog/${
node.childMdx.frontmatter.section
? node.childMdx.frontmatter.section + "/"
: ""
}${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.section ?? "general"
}/${node.childMdx.frontmatter.published}/${
node.childMdx.frontmatter.url
}`,
redirectInBrowser: true,

View file

@ -77,8 +77,8 @@
"previous": "Zurück",
"next": "Weiter",
"section": {
"blog": {
"name": "Blog",
"general": {
"name": "Allgemein",
"description": "Begleite mich in meinem spannendem Leben!"
},
"scambox": {

View file

@ -77,8 +77,8 @@
"previous": "Previous",
"next": "Next",
"section": {
"blog": {
"name": "Blog",
"general": {
"name": "General",
"description": "Read all about my exciting life!"
},
"scambox": {

View file

@ -42,8 +42,10 @@
"gatsby-plugin-remote-images": "3.2.0",
"gatsby-plugin-robots-txt": "1.6.14",
"gatsby-plugin-sass": "5.4.0",
"gatsby-plugin-sharp": "4.4.0",
"gatsby-plugin-sharp": "^4.4.0",
"gatsby-plugin-sitemap": "5.4.0",
"gatsby-remark-copy-linked-files": "^5.4.0",
"gatsby-remark-images": "^6.4.0",
"gatsby-source-filesystem": "4.4.0",
"gatsby-transformer-json": "4.4.0",
"gatsby-transformer-sharp": "4.4.0",

View file

@ -147,7 +147,10 @@ export const query = graphql`
posts: allFile(
filter: {
sourceInstanceName: { eq: "blogContent" }
childMdx: { frontmatter: { section: { eq: $section } } }
childMdx: {
body: { ne: null }
frontmatter: { section: { eq: $section } }
}
}
sort: { fields: childMdx___frontmatter___published, order: DESC }
limit: $limit

View file

@ -58,7 +58,7 @@ const BlogPost = ({ data }) => {
},
]}
>
<section className={styles.scamboxSection}>
<section className={styles.postSection}>
<article>
<h1>{data.mdx.frontmatter.title}</h1>
<span className={styles.meta}>
@ -82,7 +82,13 @@ const BlogPost = ({ data }) => {
</span>
<MDXProvider components={{ Chat }}>
<MDXRenderer>{data.mdx.body}</MDXRenderer>
<MDXRenderer
localImages={
data.mdx.frontmatter.embeddedImagesLocal
}
>
{data.mdx.body}
</MDXRenderer>
</MDXProvider>
<Utterances
@ -124,6 +130,12 @@ export const query = graphql`
name
}
section
embeddedImagesLocal {
childImageSharp {
gatsbyImageData
}
publicURL
}
}
}
locales: allLocale(filter: { language: { eq: $language } }) {

View file

@ -1,7 +1,14 @@
@import "../globals";
.scamboxSection {
.postSection {
flex-grow: 1;
> article {
img {
display: block;
margin: 0 auto;
}
}
}
.noticeBox {

View file

@ -4340,6 +4340,11 @@ css-select@~1.2.0:
domutils "1.5.1"
nth-check "~1.0.1"
css-selector-parser@^1.0.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/css-selector-parser/-/css-selector-parser-1.4.1.tgz#03f9cb8a81c3e5ab2c51684557d5aaf6d2569759"
integrity sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==
css-tree@1.0.0-alpha.37:
version "1.0.0-alpha.37"
resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22"
@ -6254,7 +6259,7 @@ gatsby-plugin-sass@5.4.0:
resolve-url-loader "^3.1.2"
sass-loader "^10.1.1"
gatsby-plugin-sharp@4.4.0:
gatsby-plugin-sharp@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/gatsby-plugin-sharp/-/gatsby-plugin-sharp-4.4.0.tgz#d3d182f1397011aeb969f4300022ff13df81e720"
integrity sha512-X2Syc6YfOD2O+5A2Lrd/l/HXHIAIjcbRfP38uJPbG0cZg3xRd3T7RaDEcDrFylHvpYZfcqjzumfwPeQuhhxUUQ==
@ -6381,6 +6386,37 @@ gatsby-recipes@^1.4.0:
xstate "^4.9.1"
yoga-layout-prebuilt "^1.9.6"
gatsby-remark-copy-linked-files@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/gatsby-remark-copy-linked-files/-/gatsby-remark-copy-linked-files-5.4.0.tgz#124e26c1576be4f7065d11d9cac5084c0da7993a"
integrity sha512-bU0jcNS5yv+WHziyxl/K3fceLyf96MQlwZzQQkGwAkfuWxEsDh15EaaT/atJbj9T0ZlccuGzXSRj7kxFlhEmPw==
dependencies:
"@babel/runtime" "^7.15.4"
cheerio "^1.0.0-rc.10"
fs-extra "^10.0.0"
is-relative-url "^3.0.0"
lodash "^4.17.21"
path-is-inside "^1.0.2"
probe-image-size "^6.0.0"
unist-util-visit "^2.0.3"
gatsby-remark-images@^6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/gatsby-remark-images/-/gatsby-remark-images-6.4.0.tgz#8a4c72a133bfedd056c432f071f3e1a3c66d2f34"
integrity sha512-yrrX96C15pvxquAL/jQb/5Kl0nUu0yNzEDtE1lB7f2bTuxdIRDkF7UM6pfEhp0N00a3ECD+eMf2QXHn/yo2tvg==
dependencies:
"@babel/runtime" "^7.15.4"
chalk "^4.1.2"
cheerio "^1.0.0-rc.10"
gatsby-core-utils "^3.4.0"
is-relative-url "^3.0.0"
lodash "^4.17.21"
mdast-util-definitions "^4.0.0"
potrace "^2.1.8"
query-string "^6.14.1"
unist-util-select "^3.0.4"
unist-util-visit-parents "^3.1.1"
gatsby-source-filesystem@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/gatsby-source-filesystem/-/gatsby-source-filesystem-4.4.0.tgz#9921ac0600166e4ee0cd561d194c2df89a42e11d"
@ -9305,6 +9341,11 @@ normalize-url@^6.0.1, normalize-url@^6.1.0:
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a"
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==
not@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/not/-/not-0.1.0.tgz#c9691c1746c55dcfbe54cbd8bd4ff041bc2b519d"
integrity sha1-yWkcF0bFXc++VMvYvU/wQbwrUZ0=
npm-run-path@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
@ -9857,6 +9898,11 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=
path-key@^2.0.0, path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
@ -12742,6 +12788,17 @@ unist-util-remove@^2.0.0:
dependencies:
unist-util-is "^4.0.0"
unist-util-select@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/unist-util-select/-/unist-util-select-3.0.4.tgz#702c9dc1db1b2bbbfe27f796fce99e43f25edc60"
integrity sha512-xf1zCu4okgPqGLdhCDpRnjwBNyv3EqjiXRUbz2SdK1+qnLMB7uXXajfzuBvvbHoQ+JLyp4AEbFCGndmc6S72sw==
dependencies:
css-selector-parser "^1.0.0"
not "^0.1.0"
nth-check "^2.0.0"
unist-util-is "^4.0.0"
zwitch "^1.0.0"
unist-util-stringify-position@^1.0.0, unist-util-stringify-position@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz#3f37fcf351279dcbca7480ab5889bb8a832ee1c6"
@ -12773,7 +12830,7 @@ unist-util-visit-parents@^2.0.0:
dependencies:
unist-util-is "^3.0.0"
unist-util-visit-parents@^3.0.0:
unist-util-visit-parents@^3.0.0, unist-util-visit-parents@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz#65a6ce698f78a6b0f56aa0e88f13801886cdaef6"
integrity sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==
@ -12781,7 +12838,7 @@ unist-util-visit-parents@^3.0.0:
"@types/unist" "^2.0.0"
unist-util-is "^4.0.0"
unist-util-visit@2.0.3, unist-util-visit@^2.0.0, unist-util-visit@^2.0.2:
unist-util-visit@2.0.3, unist-util-visit@^2.0.0, unist-util-visit@^2.0.2, unist-util-visit@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-2.0.3.tgz#c3703893146df47203bb8a9795af47d7b971208c"
integrity sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==