Skip to content

Commit

Permalink
Fix possible Cross-site Scripting (XSS) in Rest/GraphQL viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
aheinze committed Aug 19, 2023
1 parent ddc7881 commit 2a93d39
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## WIP

- Fix mime type detection on asset upload
- Fix possible Cross-site Scripting (XSS) in Rest/GraphQL viewer

## 2.6.3 (2023-08-15)

Expand Down
4 changes: 2 additions & 2 deletions modules/System/views/api/graphql-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function graphQLFetcher(graphQLParams) {

</script>

<input id="apiKey" type="text" placeholder="API Key" value="<?=($apiKey ? $apiKey : '')?>">
<input id="apiKey" type="text" placeholder="API Key" value="<?=$this->escape($apiKey ? $apiKey : '')?>">

<style>

Expand Down Expand Up @@ -223,7 +223,7 @@ function graphQLFetcher(graphQLParams) {
background: #10131a;
border: 1px solid <?=($primaryColor ? $primaryColor : '#0e8fff')?>;
box-shadow: none !important;
fill: <?=($primaryColor ? $primaryColor : '#0e8fff')?>;
fill: <?= $this->escape($primaryColor ? $primaryColor : '#0e8fff')?>;
}

.graphiql-container .history-contents p {
Expand Down
10 changes: 5 additions & 5 deletions modules/System/views/api/rest-api-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</head>
<body>
<rapi-doc
spec-url="<?=$openApiUrl?>"
spec-url="<?=$this->escape($openApiUrl)?>"
show-header="false"
show-info="false"
render-style="read"
Expand All @@ -14,12 +14,12 @@
<?php if($apiKey): ?>
api-key-name = "api-key"
api-key-location = "header"
api-key-value = "<?=$apiKey?>"
api-key-value = "<?=$this->escape($apiKey)?>"
<?php endif ?>

bg-color="<?=($bgColor ? $bgColor : '#10131a')?>"
text-color="<?=($textColor ? $textColor : '#fafafa')?>"
primary-color="<?=($primaryColor ? $primaryColor : '#0e8fff')?>"
bg-color="<?=$this->escape($bgColor ? $bgColor : '#10131a')?>"
text-color="<?= $this->escape($textColor ? $textColor : '#fafafa')?>"
primary-color="<?= $this->escape($primaryColor ? $primaryColor : '#0e8fff')?>"
></rapi-doc>

<script type="module" src="<?=$this->base('system:assets/vendor/rapidoc.js')?>"></script>
Expand Down

0 comments on commit 2a93d39

Please sign in to comment.